diff --git a/src/lib/components/FormChipCell/FormChipCell.js b/src/lib/components/FormChipCell/FormChipCell.js index 4d763ff7..44ceedc4 100644 --- a/src/lib/components/FormChipCell/FormChipCell.js +++ b/src/lib/components/FormChipCell/FormChipCell.js @@ -139,7 +139,7 @@ const FormChipCell = ({ ) const handleRemoveChip = useCallback( - (event, fields, chipIndex) => { + (event, fields, chipIndex, isOutsideClick = false) => { checkChipsList( lodash .chain(formState) @@ -149,19 +149,19 @@ const FormChipCell = ({ ) fields.remove(chipIndex) onExitEditModeCallback && onExitEditModeCallback() - event && event.stopPropagation() + event && !isOutsideClick && event.stopPropagation() }, [checkChipsList, formState, name, onExitEditModeCallback] ) const handleEditChip = useCallback( - (event, fields, nameEvent) => { + (event, fields, nameEvent, isOutsideClick) => { const { key, value } = fields.value[editConfig.chipIndex] const isChipNotEmpty = !!(key?.trim() && value?.trim()) if (nameEvent === CLICK) { if (!isChipNotEmpty) { - handleRemoveChip(event, fields, editConfig.chipIndex) + handleRemoveChip(event, fields, editConfig.chipIndex, isOutsideClick) } setEditConfig({ diff --git a/src/lib/components/FormChipCell/FormChipCellView.js b/src/lib/components/FormChipCell/FormChipCellView.js index f5d556d7..c5bf95b4 100644 --- a/src/lib/components/FormChipCell/FormChipCellView.js +++ b/src/lib/components/FormChipCell/FormChipCellView.js @@ -137,8 +137,8 @@ const FormChipCellView = React.forwardRef( chipIndex={index} chipOptions={chipOptions} editConfig={editConfig} - handleEditChip={(event, nameEvent) => - handleEditChip(event, fields, nameEvent) + handleEditChip={(event, nameEvent, isOutsideClick) => + handleEditChip(event, fields, nameEvent, isOutsideClick) } handleRemoveChip={(event, index) => handleRemoveChip(event, fields, index) diff --git a/src/lib/components/FormChipCell/NewChipForm/NewChipForm.js b/src/lib/components/FormChipCell/NewChipForm/NewChipForm.js index 673a9a03..9c013a37 100644 --- a/src/lib/components/FormChipCell/NewChipForm/NewChipForm.js +++ b/src/lib/components/FormChipCell/NewChipForm/NewChipForm.js @@ -187,7 +187,7 @@ const NewChipForm = React.forwardRef( const elementPath = event.path ?? event.composedPath?.() if (!elementPath.includes(refInputContainer.current)) { - onChange(event, CLICK) + onChange(event, CLICK, true) window.getSelection().removeAllRanges() } else { event.stopPropagation() @@ -297,7 +297,7 @@ const NewChipForm = React.forwardRef( })) } }, - [maxWidthInput, refInputKey, refInputValue, keyName] + [keyName, minWidthInput, maxWidthInput, minWidthValueInput] ) useLayoutEffect(() => {