-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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 Is Not Closing When It Has Focus And :items Is Changed #4663
Comments
Is it platform specific issue? It works normally on Firefox. |
This is being caused by this line: This happens because the updateItems event is called and triggers the menu. Because you are clicking on the button, the intended action is to blur the input and then update the items. Because this happens simultaneously, the input thinks that it is still focused and tries to open the menu. |
@johnleider I think your solution is a workaround and the issue should be reopened and fixed in the product. It is neglegent to assume an end user will simply know that a delay is needed.in this case. The more I use Vuetify, the more I come across these race conditions, and hours are spent dealing with them; It’s really starting to eat up my development budget. |
Hi @johnleider, I would like to take this as my first issue. Can you help to tell me where to start? Thank you in advance :) |
A few ideas. Pick one.
|
I understand the idea but I'm not entirely sure about the implementation. Since the problem is caused by the methods inherited from VAutocomplete component but it shouldn't be changed because it may be used in others component. In the VCombobox component, I don't know what should I change there. Thanks for the help. |
There are 2 issues here.
Let's start with the first, as it will solve many other issues as well. |
The first issue is caused by the watched items in the VAutocomplete component, specifically, the line of code @johnleider talked about. Will there be problems if we change this part? Is there any other way to fix this? |
Here is a simple test case which someone may find useful: https://codepen.io/anon/pen/djJrpx |
This change works for me:
I think the comment in the code "User is probably async loading items" makes it clear there is currently no way in the API to know definitely if the user is using async loading. By adding a check for hideNoData I think it makes a better guess. |
I don't think that fixing focus (removing nextTick from button handlers etc) will fix this issue.
The other scenario also causes this issue:
This case selecting a value will trigger computed items to update. The last will not actually change, but from js point of view the new items will be a different array, and this will trigger updateItems event as well. |
The scenario you are describing sounds like autocomplete, not combobox @Kasheftin . |
I believe this all comes down to the assumption that the update is from an async call, and that the menu should always be invoked in that case - as pointed out by @johnleider. I proposed in #4878 a simple prop to control this behaviour, a solution similar to that suggested by @johnkingsley. Given the number of reports of this behaviour as a defect, perhaps it should even default to off, and the prop would need to be used to toggle it on, in cases where it is preferred. |
I completely agree and made that comment on your PR. Let's get it in next release! |
The original commit d4732ec and unit test referred to |
Actually that watcher can probably be removed entirely, there's also a computed property that handles this much more elegantly: vuetify/src/components/VAutocomplete/VAutocomplete.js Lines 116 to 120 in 0a2e9ca
|
The If the distinct feature of opening the menu upon external Both the I understand the desire to avoid new props as generally more props equals more complexity, but I believe the tradeoff is warranted in this case since these props are really intended for cases where a little complexity is to be expected (ie, server-side querying/filtering), and flexibility appreciated. |
The items watcher is there because |
As far as I can tell,
I was under the impression that the If you're advocating for coupling the above behaviour to |
You might be right, this is why john said we should get some use cases together for #4879.
'Off' doesn't seem like it should be used there, typically it'd be a loading bar while waiting for the response instead of jumping straight to saying there's nothing there. |
Indeed, the on/off selector was only there to demonstrate that the opening of the menu is independent (and I think should remain so) of
This codepen demonstrates the async use-case that would rely on the current default behaviour of opening upon items changed, as well as making use of Some solution options:
My order of preference would be: 3 - A good balance: provides optional assumed behaviour (open the menu when items change, is not already open, has focus, and there are some items in the new list). Assumed behaviour must be enabled explicitly, component API is still available for more complex cases. |
* Filter comments to count actual rendered elements * Remove unnecesary conditional * Filter out VNodes with empty text * fix(VImg): allow transition to be disabled * fix(v-combobox): update onEnterDown logic should let v-select-list handle the update if user is selecting index fixes vuetifyjs#5008 * fix(v-slider): remove duplicate change event onMouseUp is already triggered by v-input, our mouseUp usage is more internal for slider, just renamed method fixes vuetifyjs#4996 * fix(v-combobox): prevent default action when using a combobox, enter should be treated differently and not invoke a form submit fixes vuetifyjs#4974 * fix(VMenu): make detached provide reactive fixes vuetifyjs#5010 * fix(VBreadcrumbs): add Themeable classes fixes vuetifyjs#4986 * Fix vuetifyjs#3904: dividers are not shown in dynamic vertical stepper (vuetifyjs#4767) * Fix vuetifyjs#4696: Checkbox is hard to click with ripple disabled (vuetifyjs#4776) * test(v-stepper-ccontent): add provide * [release] 1.2.2 * V-Autocomplete: hide-no-data also controls opening menu upon item update fixes vuetifyjs#4663 * fix(v-footer): fix applicationProperty update add new value for inset footer to applicationable fixes vuetifyjs#4686 * [release] 1.1.16 * [release] 1.2.3 * fix(VMenu): inherit light/dark from v-app playground: https://pastebin.com/raw/jtLrtVtP * fix(DatePicker): Title spacing when month === August (vuetifyjs#5027) * fix(v-autocomplete): add conditional for single-line fixes vuetifyjs#5076 * fix(v-list-tile-action): add support for v-html fixes vuetifyjs#5037 * fix(v-navigation-drawer): pull in Dependent mixin for click-outside * feat(v-carousel): convert to ts * refactor(v-carousel): update review items * chore(v-carousel): update type * refactor(v-carousel): update feedback items * feat(dependent): convert to ts * feat(filterable): convert to ts * feat(returnable): convert to ts * feat(components-index): convert to ts * feat(colorable): convert to ts * refactor(colors.d.ts): move file * fix(translatable): partially revert 5f661a3 reverted back to original logic to correct scrolling bug fixes vuetifyjs#4847 * [release] 1.2.4 * style(v-pagination): button cutting the page number When props:length is a very large number, the number of the button protrudes. # <type>: (If applied, this commit will...) <subject> (Max 50 char) # |<---- Using a Maximum Of 50 Characters ---->| Hard limit to 72 -->| # Explain why this change is being made # |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->| # Provide links to any relevant issues, articles, commits, or other # pull requests # Example: See #23, fixes vuetifyjs#58 # --- COMMIT END --- # <type> can be # feat (new feature) # fix (bug fix) # refactor (refactoring production code) # style (formatting, missing semi colons, etc; no code change) # test (adding or refactoring tests; no production code change) # chore (updating npm scripts etc; no production code change) # -------------------- # Remember to # Capitalize the subject line # Use the imperative mood in the subject line # Do not end the subject line with a period # Separate subject from body with a blank line (comments don't count) # Use the body to explain what and why vs. how # Can use multiple lines with "-" for bullet points in body # # If you can't summarize your changes in a single line, they should # probably be split into multiple commits # -------------------- # For more information about this template, check out # https://gist.github.com/adeekshith/cd4c95a064977cdc6c50 * fix(iterable): rows-per-page selector not inheriting theme * [release] 1.2.5 * fix(VStepperStep): use colorable mixin fixes vuetifyjs#5183 * test for vuetifyjs#5183 * Fix vuetifyjs#4760: show next pagination page if current page is last * [release] 1.2.6
* Filter comments to count actual rendered elements * Remove unnecesary conditional * Filter out VNodes with empty text * fix(VImg): allow transition to be disabled * fix(v-combobox): update onEnterDown logic should let v-select-list handle the update if user is selecting index fixes vuetifyjs#5008 * fix(v-slider): remove duplicate change event onMouseUp is already triggered by v-input, our mouseUp usage is more internal for slider, just renamed method fixes vuetifyjs#4996 * fix(v-combobox): prevent default action when using a combobox, enter should be treated differently and not invoke a form submit fixes vuetifyjs#4974 * fix(VMenu): make detached provide reactive fixes vuetifyjs#5010 * fix(VBreadcrumbs): add Themeable classes fixes vuetifyjs#4986 * Fix vuetifyjs#3904: dividers are not shown in dynamic vertical stepper (vuetifyjs#4767) * Fix vuetifyjs#4696: Checkbox is hard to click with ripple disabled (vuetifyjs#4776) * test(v-stepper-ccontent): add provide * [release] 1.2.2 * V-Autocomplete: hide-no-data also controls opening menu upon item update fixes vuetifyjs#4663 * fix(v-footer): fix applicationProperty update add new value for inset footer to applicationable fixes vuetifyjs#4686 * [release] 1.1.16 * [release] 1.2.3 * fix(VMenu): inherit light/dark from v-app playground: https://pastebin.com/raw/jtLrtVtP * fix(DatePicker): Title spacing when month === August (vuetifyjs#5027) * fix(v-autocomplete): add conditional for single-line fixes vuetifyjs#5076 * fix(v-list-tile-action): add support for v-html fixes vuetifyjs#5037 * fix(v-navigation-drawer): pull in Dependent mixin for click-outside * feat(v-carousel): convert to ts * refactor(v-carousel): update review items * chore(v-carousel): update type * refactor(v-carousel): update feedback items * feat(dependent): convert to ts * feat(filterable): convert to ts * feat(returnable): convert to ts * feat(components-index): convert to ts * feat(colorable): convert to ts * refactor(colors.d.ts): move file * fix(translatable): partially revert 5f661a3 reverted back to original logic to correct scrolling bug fixes vuetifyjs#4847 * [release] 1.2.4 * style(v-pagination): button cutting the page number When props:length is a very large number, the number of the button protrudes. # <type>: (If applied, this commit will...) <subject> (Max 50 char) # |<---- Using a Maximum Of 50 Characters ---->| Hard limit to 72 -->| # Explain why this change is being made # |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->| # Provide links to any relevant issues, articles, commits, or other # pull requests # Example: See #23, fixes vuetifyjs#58 # --- COMMIT END --- # <type> can be # feat (new feature) # fix (bug fix) # refactor (refactoring production code) # style (formatting, missing semi colons, etc; no code change) # test (adding or refactoring tests; no production code change) # chore (updating npm scripts etc; no production code change) # -------------------- # Remember to # Capitalize the subject line # Use the imperative mood in the subject line # Do not end the subject line with a period # Separate subject from body with a blank line (comments don't count) # Use the body to explain what and why vs. how # Can use multiple lines with "-" for bullet points in body # # If you can't summarize your changes in a single line, they should # probably be split into multiple commits # -------------------- # For more information about this template, check out # https://gist.github.com/adeekshith/cd4c95a064977cdc6c50 * fix(iterable): rows-per-page selector not inheriting theme * [release] 1.2.5 * fix(VStepperStep): use colorable mixin fixes vuetifyjs#5183 * test for vuetifyjs#5183 * Fix vuetifyjs#4760: show next pagination page if current page is last * [release] 1.2.6 * fix(v-radio): remove bottom margin if only or last child, do not add margin fixes vuetifyjs#5162 * fix(v-autocomplete): allow setSearch for numeric 0 fixes vuetifyjs#5110 * [v-tab] Fix anchor hash routing (vuetifyjs#5124) * fix(v-messages): change assigned key fixes vuetifyjs#4880 * fix(v-select): remove change event for external changes fixes vuetifyjs#5006 * fix(v-text-field): change mouseup focus to conditional should only focus the input if the originating mousedown was on the element fixes vuetifyjs#5018 * fix(VLinearProgress): invalid class applied when using css color * fix(VEditDialog): apply theme classes to content (vuetifyjs#5152) * fix(VEditDialog): apply theme classes to content fixes vuetifyjs#5127 * test: update snapshots * [release] 1.2.7 * Update snapshots after merge.
* Filter comments to count actual rendered elements * Remove unnecesary conditional * Filter out VNodes with empty text * fix(VImg): allow transition to be disabled * fix(v-combobox): update onEnterDown logic should let v-select-list handle the update if user is selecting index fixes vuetifyjs#5008 * fix(v-slider): remove duplicate change event onMouseUp is already triggered by v-input, our mouseUp usage is more internal for slider, just renamed method fixes vuetifyjs#4996 * fix(v-combobox): prevent default action when using a combobox, enter should be treated differently and not invoke a form submit fixes vuetifyjs#4974 * fix(VMenu): make detached provide reactive fixes vuetifyjs#5010 * fix(VBreadcrumbs): add Themeable classes fixes vuetifyjs#4986 * Fix vuetifyjs#3904: dividers are not shown in dynamic vertical stepper (vuetifyjs#4767) * Fix vuetifyjs#4696: Checkbox is hard to click with ripple disabled (vuetifyjs#4776) * test(v-stepper-ccontent): add provide * [release] 1.2.2 * V-Autocomplete: hide-no-data also controls opening menu upon item update fixes vuetifyjs#4663 * fix(v-footer): fix applicationProperty update add new value for inset footer to applicationable fixes vuetifyjs#4686 * [release] 1.1.16 * [release] 1.2.3 * fix(VMenu): inherit light/dark from v-app playground: https://pastebin.com/raw/jtLrtVtP * fix(DatePicker): Title spacing when month === August (vuetifyjs#5027) * fix(v-autocomplete): add conditional for single-line fixes vuetifyjs#5076 * fix(v-list-tile-action): add support for v-html fixes vuetifyjs#5037 * fix(v-navigation-drawer): pull in Dependent mixin for click-outside * feat(v-carousel): convert to ts * refactor(v-carousel): update review items * chore(v-carousel): update type * refactor(v-carousel): update feedback items * feat(dependent): convert to ts * feat(filterable): convert to ts * feat(returnable): convert to ts * feat(components-index): convert to ts * feat(colorable): convert to ts * refactor(colors.d.ts): move file * fix(translatable): partially revert 5f661a3 reverted back to original logic to correct scrolling bug fixes vuetifyjs#4847 * [release] 1.2.4 * style(v-pagination): button cutting the page number When props:length is a very large number, the number of the button protrudes. # <type>: (If applied, this commit will...) <subject> (Max 50 char) # |<---- Using a Maximum Of 50 Characters ---->| Hard limit to 72 -->| # Explain why this change is being made # |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->| # Provide links to any relevant issues, articles, commits, or other # pull requests # Example: See #23, fixes vuetifyjs#58 # --- COMMIT END --- # <type> can be # feat (new feature) # fix (bug fix) # refactor (refactoring production code) # style (formatting, missing semi colons, etc; no code change) # test (adding or refactoring tests; no production code change) # chore (updating npm scripts etc; no production code change) # -------------------- # Remember to # Capitalize the subject line # Use the imperative mood in the subject line # Do not end the subject line with a period # Separate subject from body with a blank line (comments don't count) # Use the body to explain what and why vs. how # Can use multiple lines with "-" for bullet points in body # # If you can't summarize your changes in a single line, they should # probably be split into multiple commits # -------------------- # For more information about this template, check out # https://gist.github.com/adeekshith/cd4c95a064977cdc6c50 * fix(iterable): rows-per-page selector not inheriting theme * [release] 1.2.5 * fix(VStepperStep): use colorable mixin fixes vuetifyjs#5183 * test for vuetifyjs#5183 * Fix vuetifyjs#4760: show next pagination page if current page is last * [release] 1.2.6 * fix(v-radio): remove bottom margin if only or last child, do not add margin fixes vuetifyjs#5162 * fix(v-autocomplete): allow setSearch for numeric 0 fixes vuetifyjs#5110 * [v-tab] Fix anchor hash routing (vuetifyjs#5124) * fix(v-messages): change assigned key fixes vuetifyjs#4880 * fix(v-select): remove change event for external changes fixes vuetifyjs#5006 * fix(v-text-field): change mouseup focus to conditional should only focus the input if the originating mousedown was on the element fixes vuetifyjs#5018 * fix(VLinearProgress): invalid class applied when using css color * fix(VEditDialog): apply theme classes to content (vuetifyjs#5152) * fix(VEditDialog): apply theme classes to content fixes vuetifyjs#5127 * test: update snapshots * [release] 1.2.7 * fix(v-ripple): decrease click target size on selection control ripple (vuetifyjs#5250) hopefully removes instances where click targets overlap between adjacent inputs closes vuetifyjs#2661 * fix(v-stepper): add registrable mixin fixes vuetifyjs#3330 * fix(v-select): change isDisabled conditional should use regular text color when readonly fixes vuetifyjs#5051 * fix(v-dialog): always remove scrollbar when fullscreen fixes vuetifyjs#3101 * fix(v-ripple): only modify position if current one is static (vuetifyjs#5249) * fix(v-ripple): only modify position if current one is static solves problems when using for example position sticky closes vuetifyjs#2573 * chore(ripple): ignore eslint for max-statements * [release] 1.2.8
Versions and Environment
Vuetify: 1.1.5
Vue: 2.5.17
Browsers: chrome
OS: osx
Steps to reproduce
select item 2
press button (with cursor still in combobox)
Expected Behavior
menu should not open, and then should close
Actual Behavior
menu opens when changing items and will not close
Reproduction Link
https://codepen.io/Flamenco/pen/pZEqGo?editors=1111
The text was updated successfully, but these errors were encountered: