Skip to content

Commit 969d418

Browse files
committed
refactor: SelectPickerTextArea - code refactor
1 parent 5802f2e commit 969d418

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/Common/Constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ export enum ReactSelectInputAction {
509509
selectOption = 'select-option',
510510
deselectOption = 'deselect-option',
511511
removeValue = 'remove-value',
512+
inputBlur = 'input-blur',
512513
}
513514

514515
export const ZERO_TIME_STRING = '0001-01-01T00:00:00Z'

src/Shared/Components/DynamicDataTable/DynamicDataTableRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const DynamicDataTableRow = <K extends string, CustomStateType = Record<s
7676
}
7777

7878
useEffect(() => {
79-
setIsRowAdded(rows.length && Object.keys(cellRef.current).length < rows.length)
79+
setIsRowAdded(rows.length > 0 && Object.keys(cellRef.current).length < rows.length)
8080
const rowIds = rows.map(({ id }) => id)
8181

8282
const updatedCellRef = rowIds.reduce((acc, curr) => {

src/Shared/Components/SelectPicker/SelectPickerTextArea.component.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useEffect, useRef, useState } from 'react'
22
import { InputActionMeta, SelectInstance, SingleValue } from 'react-select'
33

4+
import { ReactSelectInputAction } from '@Common/Constants'
5+
46
import SelectPicker from './SelectPicker.component'
57
import { SelectPickerOptionType, SelectPickerTextAreaProps } from './type'
68

@@ -24,15 +26,15 @@ export const SelectPickerTextArea = ({
2426

2527
// METHODS
2628
const onInputChange = (newValue: string, { action }: InputActionMeta) => {
27-
if (action === 'input-change') {
29+
if (action === ReactSelectInputAction.inputChange) {
2830
setInputValue(newValue)
2931
if (!newValue) {
3032
onChange?.(null, {
3133
action: 'remove-value',
3234
removedValue: value as SingleValue<SelectPickerOptionType<string>>,
3335
})
3436
}
35-
} else if (action === 'input-blur') {
37+
} else if (action === ReactSelectInputAction.inputBlur) {
3638
// Reverting input to previously selected value in case of blur event. (no-selection)
3739
const selectValue = value as SingleValue<SelectPickerOptionType<string>>
3840
setInputValue(selectValue?.value || '')

0 commit comments

Comments
 (0)