diff options
author | MCMXC <16797721+mcmxcdev@users.noreply.github.com> | 2023-12-07 22:37:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-07 22:37:37 -0700 |
commit | a774c879d4cf08a76fc404771883807d27465265 (patch) | |
tree | 202c9afdeb4830d417e0ec7137a01e7981c8651c /src/components/ui | |
parent | 6.6.1-nightly.17 [skip ci] (diff) | |
download | ferdium-app-a774c879d4cf08a76fc404771883807d27465265.tar.gz ferdium-app-a774c879d4cf08a76fc404771883807d27465265.tar.zst ferdium-app-a774c879d4cf08a76fc404771883807d27465265.zip |
refactor: code cleanup (#1476)
- auto update `settings.json` due to new vscode version
- replace deprecated `e.keyCode` with `e.key`
- fix various code snippets with sonarlint and other lint plugins
Diffstat (limited to 'src/components/ui')
-rw-r--r-- | src/components/ui/AppLoader/index.tsx | 2 | ||||
-rw-r--r-- | src/components/ui/input/scorePassword.ts | 2 | ||||
-rw-r--r-- | src/components/ui/select/index.tsx | 21 |
3 files changed, 6 insertions, 19 deletions
diff --git a/src/components/ui/AppLoader/index.tsx b/src/components/ui/AppLoader/index.tsx index 64c840aaa..4b5828ef4 100644 --- a/src/components/ui/AppLoader/index.tsx +++ b/src/components/ui/AppLoader/index.tsx | |||
@@ -61,7 +61,7 @@ class AppLoader extends Component<IProps, IState> { | |||
61 | className={classes.component} | 61 | className={classes.component} |
62 | spinnerColor={theme.colorAppLoaderSpinner} | 62 | spinnerColor={theme.colorAppLoaderSpinner} |
63 | > | 63 | > |
64 | {texts?.map((text, i) => ( | 64 | {texts.map((text, i) => ( |
65 | <span | 65 | <span |
66 | key={text} | 66 | key={text} |
67 | className={classnames({ | 67 | className={classnames({ |
diff --git a/src/components/ui/input/scorePassword.ts b/src/components/ui/input/scorePassword.ts index 59502e2b0..4a9f67265 100644 --- a/src/components/ui/input/scorePassword.ts +++ b/src/components/ui/input/scorePassword.ts | |||
@@ -33,7 +33,7 @@ export function scorePasswordFunc(password: string): number { | |||
33 | 33 | ||
34 | let variationCount = 0; | 34 | let variationCount = 0; |
35 | for (const key of Object.keys(variations)) { | 35 | for (const key of Object.keys(variations)) { |
36 | variationCount += variations[key] === true ? 1 : 0; | 36 | variationCount += variations[key] ? 1 : 0; |
37 | } | 37 | } |
38 | 38 | ||
39 | score += (variationCount - 1) * 10; | 39 | score += (variationCount - 1) * 10; |
diff --git a/src/components/ui/select/index.tsx b/src/components/ui/select/index.tsx index c06ac59b0..0d8520f58 100644 --- a/src/components/ui/select/index.tsx +++ b/src/components/ui/select/index.tsx | |||
@@ -282,23 +282,23 @@ class SelectComponent extends Component<IProps, IState> { | |||
282 | 282 | ||
283 | if (!open) return; | 283 | if (!open) return; |
284 | 284 | ||
285 | if (e.keyCode === 38 || e.keyCode === 40) { | 285 | if (e.key === 'ArrowUp' || e.key === 'ArrowDown') { |
286 | e.preventDefault(); | 286 | e.preventDefault(); |
287 | } | 287 | } |
288 | 288 | ||
289 | if (this.componentRef?.current) { | 289 | if (this.componentRef?.current) { |
290 | if (e.keyCode === 38 && selected > 0) { | 290 | if (e.key === 'ArrowUp' && selected > 0) { |
291 | this.setState((state: IState) => ({ | 291 | this.setState((state: IState) => ({ |
292 | selected: state.selected - 1, | 292 | selected: state.selected - 1, |
293 | })); | 293 | })); |
294 | } else if ( | 294 | } else if ( |
295 | e.keyCode === 40 && | 295 | e.key === 'ArrowDown' && |
296 | selected < Object.keys(options!).length - 1 | 296 | selected < Object.keys(options!).length - 1 |
297 | ) { | 297 | ) { |
298 | this.setState((state: IState) => ({ | 298 | this.setState((state: IState) => ({ |
299 | selected: state.selected + 1, | 299 | selected: state.selected + 1, |
300 | })); | 300 | })); |
301 | } else if (e.keyCode === 13) { | 301 | } else if (e.key === 'Enter') { |
302 | this.select(Object.keys(options!)[selected]); | 302 | this.select(Object.keys(options!)[selected]); |
303 | } | 303 | } |
304 | 304 | ||
@@ -311,19 +311,6 @@ class SelectComponent extends Component<IProps, IState> { | |||
311 | this.scrollContainerRef.current.scrollTop = topOffset - 35; | 311 | this.scrollContainerRef.current.scrollTop = topOffset - 35; |
312 | } | 312 | } |
313 | } | 313 | } |
314 | |||
315 | switch (e.keyCode) { | ||
316 | case 37: | ||
317 | case 39: | ||
318 | case 38: | ||
319 | case 40: // Arrow keys | ||
320 | case 32: { | ||
321 | break; | ||
322 | } // Space | ||
323 | default: { | ||
324 | break; | ||
325 | } // do not block other keys | ||
326 | } | ||
327 | } | 314 | } |
328 | 315 | ||
329 | render(): ReactElement { | 316 | render(): ReactElement { |