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

[Select] Simplify blur logic #17299

Merged
merged 6 commits into from
Oct 2, 2019

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Sep 3, 2019

Closes #17294

The previous implementation assumed that the open actions would actually open the select. The issue however illustrated a case where this assumption didn't hold which caused a broken looking UI (which could be restore by bluring manually).

The overall problem is that using InputBase is the wrong abstraction. We're abusing the focused state of the input to display the select as active. The trigger isn't focused anymore. So far nobody complained so I guess this is ok to keep. Just something we need to keep in mind.

@eps1lon eps1lon added bug 🐛 Something doesn't work component: select This is the name of the generic UI component, not the React module! labels Sep 3, 2019
@eps1lon eps1lon changed the title [Selecŧ] Simplify blur logic [Select] Simplify blur logic Sep 3, 2019
@mui-pr-bot
Copy link

mui-pr-bot commented Sep 3, 2019

Details of bundle changes.

Comparing: 40fad15...9cd829b

bundle parsed diff gzip diff prev parsed current parsed prev gzip current gzip
@material-ui/core -0.06% -0.03% 334,392 334,201 91,184 91,155
@material-ui/core/Paper 0.00% 0.00% 69,049 69,049 20,524 20,524
@material-ui/core/Paper.esm 0.00% 0.00% 62,377 62,377 19,276 19,276
@material-ui/core/Popper 0.00% 0.00% 28,405 28,405 10,179 10,179
@material-ui/core/Textarea 0.00% 0.00% 5,082 5,082 2,134 2,134
@material-ui/core/TrapFocus 0.00% 0.00% 3,766 3,766 1,597 1,597
@material-ui/core/styles/createMuiTheme 0.00% 0.00% 16,351 16,351 5,821 5,821
@material-ui/core/useMediaQuery 0.00% 0.00% 2,488 2,488 1,052 1,052
@material-ui/lab 0.00% 0.00% 143,406 143,406 43,818 43,818
@material-ui/styles 0.00% 0.00% 51,780 51,780 15,355 15,355
@material-ui/system 0.00% 0.00% 15,583 15,583 4,339 4,339
Button 0.00% 0.00% 79,148 79,148 24,122 24,122
Modal 0.00% 0.00% 14,542 14,542 5,113 5,113
Portal 0.00% 0.00% 2,907 2,907 1,316 1,316
Rating 0.00% 0.00% 70,239 70,239 21,941 21,941
Slider 0.00% 0.00% 75,380 75,380 23,272 23,272
colorManipulator 0.00% 0.00% 3,835 3,835 1,519 1,519
docs.landing 0.00% 0.00% 54,267 54,267 14,344 14,344
docs.main 0.00% 0.00% 588,954 588,954 188,297 188,297
packages/material-ui/build/umd/material-ui.production.min.js -0.06% -0.04% 305,347 305,160 87,830 87,791

Generated by 🚫 dangerJS against 9cd829b

onClick={disabled || readOnly ? null : handleClick}
/* prevent focusing the trigger since we'll open anyway and move focus */
onMouseDown={e => e.preventDefault()}
Copy link
Member Author

@eps1lon eps1lon Sep 3, 2019

Choose a reason for hiding this comment

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

Otherwise the trigger gets focused applying styles that are immediately removed because we focus an option in the listbox i.e. what the comment says 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

We want to display the select in active state since this is closer to the native select but does not follow WAI-ARIA.

@eps1lon eps1lon force-pushed the fix/select/blur-controlled branch from de48b3f to 236a94b Compare October 1, 2019 13:40
@eps1lon eps1lon marked this pull request as ready for review October 1, 2019 13:53
expect(container.querySelector('[for="age-simple"]')).to.have.class('focused-label');
});

it('does not stays in an active state if an open action did not actually open', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This actually breaks on master confirming what we see in #17294

Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

Looks great

The trigger isn't focused anymore. So far nobody complained so I guess this is ok to keep.

What do you mean by nobody complained? I fail to see the behavior you refer to.

Does the non-native behavior differs from the native one?

@eps1lon
Copy link
Member Author

eps1lon commented Oct 1, 2019

The trigger isn't focused anymore. So far nobody complained so I guess this is ok to keep.

What do you mean by nobody complained? I fail to see the behavior you refer to.

That is outdated. I was originally following the WAI-ARIA practices but decided to keep the old implementation (which is closer to the native select).

@oliviertassinari
Copy link
Member

Well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: select This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can not blur Select component when it is controlled
3 participants