From b3d3b0c55f02faed5a5942291e2658e5948a6c99 Mon Sep 17 00:00:00 2001 From: Vijay Raghavan Aravamudhan Date: Mon, 3 May 2021 17:17:46 +0530 Subject: Quick switch enhancements (#1326) --- src/features/quickSwitch/Component.js | 13 ++++++++++--- src/i18n/messages/src/features/quickSwitch/Component.json | 12 ++++++------ 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/features/quickSwitch/Component.js b/src/features/quickSwitch/Component.js index 0f44385e1..02a349dee 100644 --- a/src/features/quickSwitch/Component.js +++ b/src/features/quickSwitch/Component.js @@ -8,6 +8,7 @@ import { defineMessages, intlShape } from 'react-intl'; import { Input } from '@meetfranz/forms'; import { H1 } from '@meetfranz/ui'; +import { compact, invoke } from 'lodash'; import Modal from '../../components/ui/Modal'; import { state as ModalState } from '.'; import ServicesStore from '../../stores/ServicesStore'; @@ -97,6 +98,8 @@ export default @injectSheet(styles) @inject('stores', 'actions') @observer class ARROW_UP = 38; + SHIFT = 16; + ENTER = 13; TAB = 9; @@ -132,10 +135,10 @@ export default @injectSheet(styles) @inject('stores', 'actions') @observer class // Get currently shown services services() { let services = []; - if (this.state.search) { + if (this.state.search && compact(invoke(this.state.search, 'match', /^[a-z0-9]/i)).length > 0) { // Apply simple search algorythm to list of all services services = this.props.stores.services.allDisplayed; - services = services.filter(service => service.name.toLowerCase().includes(this.state.search.toLowerCase())); + services = services.filter(service => service.name.toLowerCase().search(this.state.search.toLowerCase()) !== -1); } else { // Add last used services to services array for (const service of this.props.stores.services.lastUsedServices) { @@ -204,7 +207,11 @@ export default @injectSheet(styles) @inject('stores', 'actions') @observer class this.changeSelected(1); break; case this.TAB: - this.changeSelected(1); + if (event.shiftKey) { + this.changeSelected(-1); + } else { + this.changeSelected(1); + } break; case this.ARROW_UP: this.changeSelected(-1); diff --git a/src/i18n/messages/src/features/quickSwitch/Component.json b/src/i18n/messages/src/features/quickSwitch/Component.json index d0debee0e..e112bedc1 100644 --- a/src/i18n/messages/src/features/quickSwitch/Component.json +++ b/src/i18n/messages/src/features/quickSwitch/Component.json @@ -4,11 +4,11 @@ "defaultMessage": "!!!QuickSwitch", "file": "src/features/quickSwitch/Component.js", "start": { - "line": 16, + "line": 17, "column": 9 }, "end": { - "line": 19, + "line": 20, "column": 3 } }, @@ -17,11 +17,11 @@ "defaultMessage": "!!!Search...", "file": "src/features/quickSwitch/Component.js", "start": { - "line": 20, + "line": 21, "column": 10 }, "end": { - "line": 23, + "line": 24, "column": 3 } }, @@ -30,11 +30,11 @@ "defaultMessage": "!!!Select a service with TAB, ↑ and ↓. Open a service with ENTER.", "file": "src/features/quickSwitch/Component.js", "start": { - "line": 24, + "line": 25, "column": 8 }, "end": { - "line": 27, + "line": 28, "column": 3 } } -- cgit v1.2.3-70-g09d2