Skip to content

Commit

Permalink
Fix [Feature store, Models] Label editing action issues (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
illia-prokopchuk authored Nov 12, 2024
1 parent 79eb8cf commit 16d4694
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/lib/components/FormChipCell/FormChipCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const FormChipCell = ({
)

const handleRemoveChip = useCallback(
(event, fields, chipIndex) => {
(event, fields, chipIndex, isOutsideClick = false) => {
checkChipsList(
lodash
.chain(formState)
Expand All @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/FormChipCell/FormChipCellView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/FormChipCell/NewChipForm/NewChipForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -297,7 +297,7 @@ const NewChipForm = React.forwardRef(
}))
}
},
[maxWidthInput, refInputKey, refInputValue, keyName]
[keyName, minWidthInput, maxWidthInput, minWidthValueInput]
)

useLayoutEffect(() => {
Expand Down

0 comments on commit 16d4694

Please sign in to comment.