diff options
author | Vijay A <vraravam@users.noreply.github.com> | 2023-05-28 13:48:21 +0530 |
---|---|---|
committer | Vijay A <vraravam@users.noreply.github.com> | 2023-05-28 13:48:21 +0530 |
commit | 99ca310c73024b51fed1f3077375eed7827f2c20 (patch) | |
tree | 2bd15986f448129a2291acba90ccc6bf68a233e0 /src/components/ui/select/index.tsx | |
parent | Disable in-app auto-updates for portable windows installation (fixes #1088) (... (diff) | |
download | ferdium-app-99ca310c73024b51fed1f3077375eed7827f2c20.tar.gz ferdium-app-99ca310c73024b51fed1f3077375eed7827f2c20.tar.zst ferdium-app-99ca310c73024b51fed1f3077375eed7827f2c20.zip |
Fix issues reported by sonarqube linter
Diffstat (limited to 'src/components/ui/select/index.tsx')
-rw-r--r-- | src/components/ui/select/index.tsx | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/components/ui/select/index.tsx b/src/components/ui/select/index.tsx index 695e70e28..017de5423 100644 --- a/src/components/ui/select/index.tsx +++ b/src/components/ui/select/index.tsx | |||
@@ -17,7 +17,7 @@ import Wrapper from '../wrapper'; | |||
17 | let popupTransition: string = 'none'; | 17 | let popupTransition: string = 'none'; |
18 | let toggleTransition: string = 'none'; | 18 | let toggleTransition: string = 'none'; |
19 | 19 | ||
20 | if (window && window.matchMedia('(prefers-reduced-motion: no-preference)')) { | 20 | if (window?.matchMedia('(prefers-reduced-motion: no-preference)')) { |
21 | popupTransition = 'all 0.3s'; | 21 | popupTransition = 'all 0.3s'; |
22 | toggleTransition = 'transform 0.3s'; | 22 | toggleTransition = 'transform 0.3s'; |
23 | } | 23 | } |
@@ -194,13 +194,13 @@ class SelectComponent extends Component<IProps, IState> { | |||
194 | componentDidUpdate(): void { | 194 | componentDidUpdate(): void { |
195 | const { open } = this.state; | 195 | const { open } = this.state; |
196 | 196 | ||
197 | if (this.searchInputRef && this.searchInputRef.current && open) { | 197 | if (this.searchInputRef?.current && open) { |
198 | this.searchInputRef.current.focus(); | 198 | this.searchInputRef.current.focus(); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | componentDidMount(): void { | 202 | componentDidMount(): void { |
203 | if (this.inputRef && this.inputRef.current) { | 203 | if (this.inputRef?.current) { |
204 | const { data } = this.props; | 204 | const { data } = this.props; |
205 | 205 | ||
206 | if (data) { | 206 | if (data) { |
@@ -215,7 +215,7 @@ class SelectComponent extends Component<IProps, IState> { | |||
215 | UNSAFE_componentWillMount(): void { | 215 | UNSAFE_componentWillMount(): void { |
216 | const { value } = this.props; | 216 | const { value } = this.props; |
217 | 217 | ||
218 | if (this.componentRef && this.componentRef.current) { | 218 | if (this.componentRef?.current) { |
219 | this.componentRef.current.removeEventListener( | 219 | this.componentRef.current.removeEventListener( |
220 | 'keydown', | 220 | 'keydown', |
221 | this.keyListener, | 221 | this.keyListener, |
@@ -285,7 +285,7 @@ class SelectComponent extends Component<IProps, IState> { | |||
285 | e.preventDefault(); | 285 | e.preventDefault(); |
286 | } | 286 | } |
287 | 287 | ||
288 | if (this.componentRef && this.componentRef.current) { | 288 | if (this.componentRef?.current) { |
289 | if (e.keyCode === 38 && selected > 0) { | 289 | if (e.keyCode === 38 && selected > 0) { |
290 | this.setState((state: IState) => ({ | 290 | this.setState((state: IState) => ({ |
291 | selected: state.selected - 1, | 291 | selected: state.selected - 1, |
@@ -302,8 +302,7 @@ class SelectComponent extends Component<IProps, IState> { | |||
302 | } | 302 | } |
303 | 303 | ||
304 | if ( | 304 | if ( |
305 | this.activeOptionRef && | 305 | this.activeOptionRef?.current && |
306 | this.activeOptionRef.current && | ||
307 | this.scrollContainerRef && | 306 | this.scrollContainerRef && |
308 | this.scrollContainerRef.current | 307 | this.scrollContainerRef.current |
309 | ) { | 308 | ) { |
@@ -350,13 +349,11 @@ class SelectComponent extends Component<IProps, IState> { | |||
350 | 349 | ||
351 | const { open, needle, value, selected, options } = this.state; | 350 | const { open, needle, value, selected, options } = this.state; |
352 | 351 | ||
353 | let selection = ''; | 352 | let selection = actionText; |
354 | if (!value && defaultValue && options![defaultValue]) { | 353 | if (!value && defaultValue && options![defaultValue]) { |
355 | selection = options![defaultValue]; | 354 | selection = options![defaultValue]; |
356 | } else if (value && options![value]) { | 355 | } else if (value && options![value]) { |
357 | selection = options![value]; | 356 | selection = options![value]; |
358 | } else { | ||
359 | selection = actionText; | ||
360 | } | 357 | } |
361 | 358 | ||
362 | return ( | 359 | return ( |