Skip to content

Commit

Permalink
fix(NcSelect): stop propagation of ESC on closing select
Browse files Browse the repository at this point in the history
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
  • Loading branch information
ShGKme committed Sep 7, 2023
1 parent c9c1953 commit da9582d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/components/NcSelect/NcSelect.vue
Expand Up @@ -768,6 +768,39 @@ export default {
default: '',
},
/**
* Customized component's response to keydown events while the search input has focus
*
* @see https://vue-select.org/guide/keydown.html#mapkeydown
*/
mapKeydown: {
type: Function,
/**
* Patched Vue-Select keydown events handlers map to stop Escape propagation in open select
*
* @param {Record<number, Function>} map - Mapped keyCode to handlers { <keyCode>:<callback> }
* @param {import('@nextcloud/vue-select').VueSelect} vm - VueSelect instance
* @return {Record<number, Function>} patched keydown event handlers
*/
default(map, vm) {
return {
...map,
/**
* Patched Escape handler to stop propagation from open select
*
* @param {KeyboardEvent} event - default keydown event handler
*/
27: (event) => {
if (vm.open) {
event.stopPropagation()
}
// Default VueSelect's handler
map[27](event)
},
}
},
},
/**
* When `appendToBody` is true, this sets the placement of the dropdown
*
Expand Down

0 comments on commit da9582d

Please sign in to comment.