-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15673 from redstar504/Brayden-PickerIndicator
Add additional events for controlling picker indicator on web
- Loading branch information
Showing
3 changed files
with
64 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, {forwardRef} from 'react'; | ||
import BasePicker from './Picker'; | ||
|
||
const additionalPickerEvents = (onMouseDown, onChange) => ({ | ||
onMouseDown, | ||
onChange: (e) => { | ||
if (e.target.selectedIndex === undefined) { | ||
return; | ||
} | ||
const index = e.target.selectedIndex; | ||
const value = e.target.options[index].value; | ||
onChange(value, index); | ||
}, | ||
}); | ||
|
||
export default forwardRef((props, ref) => ( | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
<BasePicker {...props} additionalPickerEvents={additionalPickerEvents} ref={ref} /> | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React, {forwardRef} from 'react'; | ||
import BasePicker from './Picker'; | ||
|
||
export default forwardRef((props, ref) => ( | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
<BasePicker {...props} ref={ref} /> | ||
)); |