vuetify icon indicating copy to clipboard operation
vuetify copied to clipboard

[Bug Report][3.3.7] closeOnContentClick in menuProps for VCombobox doesn't work when item is selected using keyboard

Open Maxim-Mazurok opened this issue 1 year ago • 2 comments

Environment

Vuetify Version: 3.3.7 Vue Version: 3.3.2 Browsers: Chrome 114.0.0.0 OS: Windows 10

Steps to reproduce

  1. Click on combobox
  2. Use arrow keys to select some option
  3. Press enter

Expected Behavior

Combobox is closed

Actual Behavior

Combobox stays open

Reproduction Link

https://play.vuetifyjs.com/#...

Other comments

When you do same steps but click on the item instead of using Enter to select it with keyboard - combobox is getting closed as expected.

Here's a potential workaround that I don't want to use:

<VListItem
  onClick={() => {
    // The following is a workaround, probably isn't worth it, should be reported, see `- [ ] `VCombobox` - `closeOnContentClick` in `menuProps` doesn't close menu when list item selected with keyboard (by pressing Enter)`
    // const actualKeyword = keyword.value; // save current keyword before it's overwritten by the click handler
    // (props.onClick as () => void)(); // trigger the default `select()` method of the combobox
    // keyword.value = actualKeyword; // restore the original keyword
    openResult(item.raw.collectionPK, item.raw.pk!);
  }}
>

My use-case is that I use combobox for search. And I don't want it to change model value on selection. Basically user types into combobox, as he types we query server for results, then user clicks on a result or selects it with keyboard and result opens, combobox clothes and the original search query remains in the box.

Perhaps I'm abusing combobox... But would be great to have this resolved somehow. Thank you!

Maxim-Mazurok avatar Jul 11 '23 04:07 Maxim-Mazurok

Why do you need closeOnContentClick, it closes if you bind the slot props correctly: https://play.vuetifyjs.com/#eNqlUstu2zAQ/JUtL0oASzykQAEjDlIYaHtuC+Rg+SBLa5stXyDXbgLD/94lJdWKcwnQGzk7uzM75OokPntfHQ8o5uKe0HjdED7UFuD+WDbe52O+tM5SoyyGARpAs3Eb9zxCALrZoF7UYjlWxKU2V6wQubgqlo1WWxesaooZFEunXWg6l85f+Ki6DH9FF3Y94yc+NzEdnl6cUXZXrC+D/xliS+MKcCyjdpQVWfAEPjgf4VyLCTuvoFWkMtG4ZaNsx+zMrQXMSZFGBuxBa+6MziDtWf1eTvqm8vJVhD10SWkMM0PTNBPSh/1qAl9jG5QniEiH/i2U8S4QnCDgFs6wDc5Awe9XJDoAz40EJu5gkRg3xTfU2sGTC7r7UNxOSRE1tvQDm9Duv2M8aOKem1tYPMCpNyolWEdJUqNBS9gl/Jxc9r7YkZiJ3lJpGl/9is7yT8r99VDgJOfjxFqw1XSvxZ7Ix7mUbWe5rUOtjqGySNJ6Ix+ZJsPBkjJYds483lV31UfZceZTuMJoyk1wfyIGHlKL2USG1PblHVIDMyt86hUGqOS/HJPEm9GS9Y4YyoC2w4DhvRtdtU23uiq92WxI/sx5a2V/x6uo25hjXo0m/2vlPCxNWifB80xkn6ycG8T6L05wYcE=

KaelWD avatar Jul 20 '23 13:07 KaelWD

It does close, however as per my description above, the default onClick has an unwanted side-effect - it will change the Combobox input value to the text of the selected item.

Here's a quick demonstration of what we need in the actual product VS what we get when binding props:

https://github.com/vuetifyjs/vuetify/assets/7756211/1bad7c55-4ed9-471e-a70f-bbb363b5aedc

Maxim-Mazurok avatar Jul 24 '23 05:07 Maxim-Mazurok

@KaelWD could you please reopen this one? I didn't have a chance to un-stale it.

Maxim-Mazurok avatar Mar 17 '24 05:03 Maxim-Mazurok

@johnleider please reopen, thank you!

Maxim-Mazurok avatar Mar 20 '24 02:03 Maxim-Mazurok