Skip to content

Commit

Permalink
Merge pull request #190 from linea-it/188-bug-in-column-association
Browse files Browse the repository at this point in the history
Fixed #188 delete last character with backspace
  • Loading branch information
jandsonrj authored Aug 25, 2023
2 parents 994e9fd + 2cbd0a8 commit 0bcad25
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions frontend/components/newProduct/Step3.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,32 @@ InputUcd.propTypes = {
export function InputAlias({ pc, onChange, onChangeInputType }) {
const [value, setValue] = useState(pc.alias !== null ? pc.alias : '')

// Using lodash debounce to Delay search by 600ms
// Exemplo: https://www.upbeatcode.com/react/how-to-use-lodash-in-react/
// eslint-disable-next-line react-hooks/exhaustive-deps
const delayedEdit = useCallback(
debounce((pc, alias) => onChange(pc, alias), 600),
[]
)

const handleChange = e => {
const inputValue = e.target.value
if (inputValue.trim() !== '') {
setValue(inputValue)
delayedEdit(pc, inputValue)
}
setValue(inputValue)
}

const handleClear = () => {
setValue('')
onChange(pc, null)
}

// Using lodash debounce to Delay search by 800ms
// Exemplo: https://www.upbeatcode.com/react/how-to-use-lodash-in-react/
// eslint-disable-next-line react-hooks/exhaustive-deps
const debouncedEdit = useCallback(
debounce(updatedValue => {
if (updatedValue.trim() !== '') {
onChange(pc, updatedValue)
}
}, 800),
[]
)

useEffect(() => {
debouncedEdit(value)
}, [value, debouncedEdit])

const handleChangeType = () => {
onChangeInputType(pc.column_name)
}
Expand All @@ -155,7 +160,7 @@ export function InputAlias({ pc, onChange, onChangeInputType }) {
</InputAdornment>
)
}}
></TextField>
/>
<IconButton onClick={handleChangeType}>
<EditIcon color="primary" />
</IconButton>
Expand Down Expand Up @@ -298,7 +303,7 @@ export default function NewProductStep3({ productId, onNext, onPrev }) {
}

// Campo de Texto para Alias
if (isInputTypeAlias(pc.column_name) === true) {
if (isInputTypeAlias(pc.column_name)) {
return (
<InputAlias
pc={pc}
Expand Down

0 comments on commit 0bcad25

Please sign in to comment.