feat: Unfocus cells when mouse leaves the table (#2442)

* feat: Unfocus cells when mouse leaves the table

* fix: only unfocus cells that are not in edit mode
This commit is contained in:
Uwem Israel 2023-11-14 15:07:41 +01:00 committed by GitHub
parent a69711429b
commit f3dfd06571
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,6 +90,7 @@ export const RecordTableV1 = ({ updateEntityMutation }: RecordTableV1Props) => {
setRowSelectedState,
resetTableRowSelection,
useMapKeyboardToSoftFocus,
getIsSomeCellInEditMode,
} = useRecordTable();
useMapKeyboardToSoftFocus();
@ -117,11 +118,17 @@ export const RecordTableV1 = ({ updateEntityMutation }: RecordTableV1Props) => {
},
});
const handleMouseLeave = () => {
const isSomeCellInEditMode = getIsSomeCellInEditMode();
if (isSomeCellInEditMode) return;
leaveTableFocus();
};
return (
<EntityUpdateMutationContext.Provider value={updateEntityMutation}>
<StyledTableWithHeader>
<StyledTableContainer>
<div ref={tableBodyRef}>
<div ref={tableBodyRef} onMouseLeave={handleMouseLeave}>
<StyledTable className="entity-table-cell">
<RecordTableHeader />
<RecordTableBodyV1 />