-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Adding onPendingValueChanged callback #4105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
ebe922e
d1c5014
51f3aa8
c9626cd
edb9901
22bf253
6c72b47
d38795d
df4f4ef
b03155c
ff7d2e6
215d6f1
33f7e26
1acb059
46d2fd4
b58225b
d98eb23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "office-ui-fabric-react", | ||
| "comment": "ComboBox adding onPendingValueSet callback prop to run when pending value is changed", | ||
| "type": "patch" | ||
| } | ||
| ], | ||
| "packageName": "office-ui-fabric-react", | ||
| "email": "madosal@microsoft.com" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -192,13 +192,17 @@ export class ComboBox extends BaseComponent<IComboBoxProps, IComboBoxState> { | |
| allowFreeform, | ||
| value, | ||
| onMenuOpen, | ||
| onMenuDismissed | ||
| onMenuDismissed, | ||
| onPendingValueSet | ||
| } = this.props; | ||
| const { | ||
| isOpen, | ||
| focused, | ||
| currentOptions, | ||
| selectedIndex, | ||
| currentPendingValueValidIndex | ||
| currentPendingValue, | ||
| currentPendingValueValidIndex, | ||
| currentPendingValueValidIndexOnHover | ||
| } = this.state; | ||
|
|
||
| // If we are newly open or are open and the pending valid index changed, | ||
|
|
@@ -243,6 +247,16 @@ export class ComboBox extends BaseComponent<IComboBoxProps, IComboBoxState> { | |
| if (!isOpen && prevState.isOpen && onMenuDismissed) { | ||
| onMenuDismissed(); | ||
| } | ||
|
|
||
| if (onPendingValueSet) { | ||
| if (currentPendingValue !== prevState.currentPendingValue) { | ||
| onPendingValueSet(undefined, undefined, currentPendingValue); | ||
| } else if (currentPendingValueValidIndexOnHover !== prevState.currentPendingValueValidIndexOnHover) { | ||
| onPendingValueSet(currentOptions[currentPendingValueValidIndexOnHover], currentPendingValueValidIndexOnHover, undefined); | ||
| } else if (currentPendingValueValidIndex !== prevState.currentPendingValueValidIndex) { | ||
| onPendingValueSet(currentOptions[currentPendingValueValidIndex], currentPendingValueValidIndex, undefined); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider pulling this into a function to keep componentDidUpdate from getting too messy
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| } | ||
| } | ||
| } | ||
|
|
||
| public componentWillUnmount() { | ||
|
|
@@ -347,7 +361,7 @@ export class ComboBox extends BaseComponent<IComboBoxProps, IComboBoxState> { | |
| styles={ this._getCaretButtonStyles() } | ||
| role='presentation' | ||
| aria-hidden={ isButtonAriaHidden } | ||
| data-is-focusable={false} | ||
| data-is-focusable={ false } | ||
| tabIndex={ -1 } | ||
| onClick={ this._onComboBoxClick } | ||
| iconProps={ buttonIconProps } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,12 @@ export interface IComboBoxProps extends ISelectableDroppableTextProps<IComboBox> | |
| */ | ||
| onChanged?: (option?: IComboBoxOption, index?: number, value?: string) => void; | ||
|
|
||
| /** | ||
| * Callback issued when the user changes the pending value in ComboBox | ||
| * If now value is set, we send undefined parameters | ||
| */ | ||
| onPendingValueSet?: (option?: IComboBoxOption, index?: number, value?: string) => void; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe |
||
|
|
||
| /** | ||
| * Function that gets invoked when the ComboBox menu is launched | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this that I don't need it anymore