Skip to content
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

Combobox: Adding fixes for onChange and onPendingValueChanged callbacks #22097

Merged
merged 6 commits into from
Mar 15, 2022

Conversation

khmakoto
Copy link
Member

Current Behavior

Right now, selecting an option in a Combobox or writing down an option if freeform is allowed will send undefined as the value of the onChange callback. Furthermore, in the case that state is changed while typing on a freeform Combobox, onPendingValueChanged is being called twice, first with the correct value and then with undefined.

New Behavior

This PR fixes some of these issues by always sending the correct value to the onChange and onPendingValueChanged callbacks. This PR does not fix the issue of onPendingValueChanged being called twice.

Notes

See this codepen for how the previous behavior looks like.

@khmakoto khmakoto added Component: ComboBox Fluent UI react (v8) Issues about @fluentui/react (v8) labels Mar 15, 2022
@khmakoto khmakoto self-assigned this Mar 15, 2022
@khmakoto khmakoto requested a review from a team as a code owner March 15, 2022 01:02
@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 15, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit cb5f420:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

@size-auditor
Copy link

size-auditor bot commented Mar 15, 2022

Asset size changes

Project Bundle Baseline Size New Size Difference
office-ui-fabric-react fluentui-react-ComboBox 233.564 kB 233.578 kB ExceedsBaseline     14 bytes
office-ui-fabric-react fluentui-react-TimePicker 223.017 kB 223.031 kB ExceedsBaseline     14 bytes

ExceedsTolerance Over Tolerance (1024 B) ExceedsBaseline Over Baseline BelowBaseline Below Baseline New New Deleted  Removed 1 kB = 1000 B

Baseline commit: c7e8d9a5ea96e3e679fcee9f5d7a88f46777bd29 (build)

@fabricteam
Copy link
Collaborator

fabricteam commented Mar 15, 2022

📊 Bundle size report

🤖 This report was generated against c7e8d9a5ea96e3e679fcee9f5d7a88f46777bd29

@fabricteam
Copy link
Collaborator

fabricteam commented Mar 15, 2022

Perf Analysis (@fluentui/react)

Scenario Render type Master Ticks PR Ticks Iterations Status
buttonNative mount 134 132 5000 Possible regression
All results

Scenario Render type Master Ticks PR Ticks Iterations Status
BaseButton mount 986 937 5000
Breadcrumb mount 2761 2759 1000
Checkbox mount 1561 1534 5000
CheckboxBase mount 1314 1313 5000
ChoiceGroup mount 4879 4849 5000
ComboBox mount 1015 1017 1000
CommandBar mount 10598 10631 1000
ContextualMenu mount 12145 12198 1000
DefaultButton mount 1159 1150 5000
DetailsRow mount 3889 3974 5000
DetailsRowFast mount 3917 3915 5000
DetailsRowNoStyles mount 3704 3668 5000
Dialog mount 2285 2264 1000
DocumentCardTitle mount 184 171 1000
Dropdown mount 3647 3356 5000
FocusTrapZone mount 1974 1931 5000
FocusZone mount 1867 1874 5000
IconButton mount 1774 1824 5000
Label mount 372 359 5000
Layer mount 2986 3065 5000
Link mount 486 486 5000
MenuButton mount 1544 1505 5000
MessageBar mount 2284 2217 5000
Nav mount 3439 3368 1000
OverflowSet mount 1116 1134 5000
Panel mount 2222 2224 1000
Persona mount 881 891 1000
Pivot mount 1500 1484 1000
PrimaryButton mount 1324 1339 5000
Rating mount 7921 7821 5000
SearchBox mount 1352 1349 5000
Shimmer mount 2560 2554 5000
Slider mount 1985 2038 5000
SpinButton mount 5134 5395 5000
Spinner mount 442 432 5000
SplitButton mount 3278 3278 5000
Stack mount 539 532 5000
StackWithIntrinsicChildren mount 2377 2364 5000
StackWithTextChildren mount 5385 5417 5000
SwatchColorPicker mount 11957 11810 5000
TagPicker mount 2775 2726 5000
TeachingBubble mount 99794 99529 5000
Text mount 454 431 5000
TextField mount 1416 1449 5000
ThemeProvider mount 1225 1218 5000
ThemeProvider virtual-rerender 670 662 5000
ThemeProvider virtual-rerender-with-unmount 1894 1883 5000
Toggle mount 819 832 5000
buttonNative mount 134 132 5000 Possible regression

Copy link
Contributor

@smhigley smhigley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value being the text of the option gets a little weird when you throw in multiSelect (e.g. un-selecting "Option B" still gets you the value "Option B"), or Select All.

I think part of the issue is that for freeform, the onChange value corresponds to the actual typed input value, and not the selected option, so it seems a bit inconsistent.

Not saying the current approach is wrong, but at a minimum we should probably document it well.

@smhigley
Copy link
Contributor

the code changes LGTM though! So if the behavior itself is desired in the multiselect/select all cases, I'll approve 👍

@khmakoto khmakoto merged commit 3afa354 into microsoft:master Mar 15, 2022
@khmakoto khmakoto deleted the comboboxOnChange branch March 15, 2022 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: ComboBox Fluent UI react (v8) Issues about @fluentui/react (v8)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants