-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[WIP] [AutoComplete] Bubble onChange, onFocus, onBlur events #2338
Conversation
…, and undefined dataSource
Yes it's 👍, you can event update the other test files if you want to. |
Just an update on this, I noticed that the main problem with the current implementation is using I'm going to recommend switching I'll give this a go tonight... |
I fear that I don't follow. |
@oliviertassinari , yes, essentially that will be where we bubble the events. However, right now the events are being called several times which may make working with them externally unnatural. For example, after debugging I noticed when you click on a (1) onFocus is called on TextField (triggers options to show) Also, each time you make a change to the What really should be happening is regardless of when options are showing or not, To properly support things like Sorry for the long explanation! Let me know if that makes any sense... |
Thanks for this long explanation. |
tl;dr If we simply bubble the events on those methods, events The proper behavior should |
…utocomplete-events
…o autocomplete-events
…o autocomplete-events
…xes, and improved docs
Hey @oliviertassinari , Sorry for the delay in pushing this! This definitely needs feedback :P. I'm not thrilled about the current implementation / what I had to change, but this latest commit fixes #2299, #2294, #2297 The main changes that facilitated those fixes were:
It's worth mentioning that there are several props that are defined on this component that now have no meaning or effect because we are no longer using That being said, making these changes makes the events work a lot more naturally. I think there are a lot of other things that we could do to improve overall API and code but wanted to push this as is as this might be the best I can do for now in terms of maintaining the original design and props/backwards compatibilty. Let me know what you think! Also, I added some more documentation and created some new examples that I think better illustrate how the component works. |
header: 'optional', | ||
desc: 'Gets called with the value when a value is selected', | ||
}, { | ||
name: 'onUpdateInput', |
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.
@newoga Please add onFocus too
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.
Will do, thanks @subjectix!
I think this component should use Popover too, but that's probably for later. This is good in my knowledge, I leave the review to @oliviertassinari and the author of auto-complete @yongxu. Please review this when you have the time. |
We plan to use the new |
@oliviertassinari, I agree. When I initially started making the switch, I underestimated the impact of the switch to I think fixing |
Can I get your feed back on this set of lines: https://github.com/callemall/material-ui/blob/master/src/lists/list-item.jsx#L379-L397 I'm trying to get a better understanding of if there is a important reason why we are using DOM focus on the As a general rule though, it may be good to design material-ui to not have dependencies on Thoughts? |
Hey @newoga, Personally, I think we shouldn't
Also, in your pull request, supporting component item has been removed.
I personally think we should allow accepting object array and let components to be used as item, so customized component can be applied. Moreover, remove this in new PR might break someone's code if they are already using it in development. I also had some thought such as other properties add be added by using object array, such as AutoComplete should not only be used as input complete, but also as search bar that can potentially show anything as its item, which was the initial motivation for me to implement this. I was thinking about something like google search bar rather than a state picker for address input. @oliviertassinari @newoga , I know the current @subjectix , Yes PopOver might be a better choice, I'd love to see that improvement and get rid of the I might be wrong on this, using List does make the code much easier to maintain and clear. I'd like to see more ideas about replace Menu with List. |
@newoga Having a look at https://www.google.com/design/spec/components/lists-controls.html#lists-controls-types-of-menu-controls.
I think that we should really use a menu. Having said that, it seems clear to me that we should fix this menu focus/blur issue. |
@oliviertassinari , @yongxu - Yup, I'm in agreement that we should not use I agree that the right approach to fixing this is finding a way to fix focus state in We should not merge this PR (I kept it as WIP) but we can ultimately close it if that's best. I haven't too much time to look into approaches to fixing menu, but as I mentioned in an earlier comment, the real problem is that there are methods on the Once again though, in general, I think we should remove all the instances of I believe we should make focus state something that is handled by a parent component, and make the List and Menu components more stateless. |
I agree.
Thank any way for this investigation. |
@oliviertassinari , my gut feeling is to maybe close this PR for now? The only thing I'd want to keep maybe are the tests I wrote and documentation. But on other hand, I know we're going through a documentation overhaul in #2433 , so maybe it makes sense to scrap and do some new docs there. And the tests are currently failing until we can fix some of the menu stuff..mmm |
Thanks anyway! |
No problem! |
@newoga Really like the tests and documents you wrote. We should definitely merge them 👍
I totally agree with you on this. Plus I think we should remove anything that securely changes the focus, or at least require explicit parameter to turn it on. They are quite annoying sometime and may cause weird behaviors sometime, very hard to work around without touching the component's code. |
Fixes #2294
Note: This PR does not implement the fix yet. I just wrote tests in
auto-complete-spec.js
that demonstrate that this is not currently supported.Earlier, I wrote a naive implementation for this, but noticed that the way focus state is currently being handled for this component is leading to some interesting behavior. Sometimes blur and focus events are being called multiple times for a single action such as clicking away from the options menu. The way the focusing is currently being handled may be a root cause to other issues as well such as #2295 and #2299.
Will look more into this...
Also, on a completely separate note, is it alright if we add a dev dependency to
react-addons-test-utils
sincereact/addons
is deprecated?