From 098ed5b1cfc5f256b21fe91482a56755a734a2e3 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Fri, 26 Apr 2024 11:02:48 -0500 Subject: [PATCH] Improve keydown handling for grid Add Filter autocomplete should work the same, but this way also works with oruga --- tailbone/templates/grids/complete.mako | 18 +++++++++++++----- tailbone/templates/grids/filters.mako | 5 ++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tailbone/templates/grids/complete.mako b/tailbone/templates/grids/complete.mako index af1a4f4d..0a5c3780 100644 --- a/tailbone/templates/grids/complete.mako +++ b/tailbone/templates/grids/complete.mako @@ -581,26 +581,34 @@ location.href = url }, - addFilterButton(event) { + addFilterInit() { this.addFilterShow = true + this.$nextTick(() => { + const input = this.$refs.addFilterAutocomplete.$el.querySelector('input') + input.addEventListener('keydown', this.addFilterKeydown) this.$refs.addFilterAutocomplete.focus() }) }, + addFilterHide() { + const input = this.$refs.addFilterAutocomplete.$el.querySelector('input') + input.removeEventListener('keydown', this.addFilterKeydown) + this.addFilterTerm = '' + this.addFilterShow = false + }, + addFilterKeydown(event) { // ESC will clear searchbox if (event.which == 27) { - this.addFilterTerm = '' - this.addFilterShow = false + this.addFilterHide() } }, addFilterSelect(filtr) { this.addFilter(filtr.key) - this.addFilterTerm = '' - this.addFilterShow = false + this.addFilterHide() }, addFilter(filter_key) { diff --git a/tailbone/templates/grids/filters.mako b/tailbone/templates/grids/filters.mako index cb6ec9e2..9a80b911 100644 --- a/tailbone/templates/grids/filters.mako +++ b/tailbone/templates/grids/filters.mako @@ -22,7 +22,7 @@ + @click="addFilterInit()"> Add Filter @@ -38,8 +38,7 @@ icon-pack="fas" clearable clear-on-select - @select="addFilterSelect" - @keydown.native="addFilterKeydown"> + @select="addFilterSelect">