Skip to content

Commit a7e18a0

Browse files
authored
Merge pull request #251 from RedisInsight/feature/bugfixing
#RI-6581, #RI-6582
2 parents fe29f4f + a84eac0 commit a7e18a0

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export enum EventKeys {
2+
ENTER = 'Enter',
3+
SPACE = ' ',
4+
ESCAPE = 'Escape',
5+
TAB = 'Tab',
6+
}

src/webviews/src/constants/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export * from './core/apiErrors'
44
export * from './core/app'
55
export * from './core/storage'
66
export * from './core/commands'
7+
export * from './core/eventKeys'
78
export * from './connections/databases'
89
export * from './keys/types'
910
export * from './keys/tree'

src/webviews/src/modules/settings/Settings.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { VscCheck } from 'react-icons/vsc'
77

88
import { Separator } from 'uiSrc/ui'
99
import { ConsentsPrivacy, MultiSelect, MultiSelectOption } from 'uiSrc/components'
10-
import { VscodeMessageAction } from 'uiSrc/constants'
10+
import { DEFAULT_DELIMITER, EventKeys, VscodeMessageAction } from 'uiSrc/constants'
1111
import { vscodeApi } from 'uiSrc/services'
1212
import { useAppInfoStore } from 'uiSrc/store/hooks/use-app-info-store/useAppInfoStore'
1313
import { TelemetryEvent, arrayToMultiSelect, multiSelectToArray, sendEventTelemetry } from 'uiSrc/utils'
@@ -27,7 +27,9 @@ export const Settings = () => {
2727
const [delimiters, setDelimiters] = useState<readonly MultiSelectOption[]>(delimitersProp)
2828

2929
const handleApplyClick = () => {
30-
const delims = multiSelectToArray(delimiters)
30+
const delimitersInit = multiSelectToArray(delimiters)
31+
const delims = delimitersInit.length ? delimitersInit : [DEFAULT_DELIMITER]
32+
3133
if (isEqual(delimitersProp, delimiters)) {
3234
return
3335
}
@@ -40,6 +42,7 @@ export const Settings = () => {
4042
},
4143
})
4244

45+
setDelimiters(arrayToMultiSelect(delims))
4346
setDelimitersAction(delims)
4447

4548
vscodeApi.postMessage({ action: VscodeMessageAction.UpdateSettingsDelimiter, data: delims })
@@ -55,8 +58,12 @@ export const Settings = () => {
5558

5659
// eslint-disable-next-line default-case
5760
switch (event.key) {
58-
case 'Enter':
59-
case ' ':
61+
case EventKeys.ENTER:
62+
case EventKeys.SPACE:
63+
if (delimiters.find(({ value }) => value === inputValue)) {
64+
return
65+
}
66+
6067
setOption()
6168
event.preventDefault()
6269
}

0 commit comments

Comments
 (0)