Skip to content

Commit

Permalink
Fix: max seat selection check
Browse files Browse the repository at this point in the history
  • Loading branch information
Akalanka47000 committed Apr 7, 2024
1 parent d6c7e4e commit 6fe97ea
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/workspace/elements/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,22 @@ export const Element: React.FC<IElementProps> = ({
if (type !== ElementType.Seat || props.status !== SeatStatus.Available) {
return;
}
}
const maxSeatSelectionCheck = () => {
if (
consumer.options?.maxSeatSelectionCount &&
store.getState().editor.selectedElementIds.length > consumer.options?.maxSeatSelectionCount
) {
return consumer.events?.onMaxSeatSelectionCountReached?.();
consumer.events?.onMaxSeatSelectionCountReached?.();
return true;
}
}
return false;
};
if (consumer.mode === "user" && consumer.seatSelectionMode === "chain") {
if (isSelected) {
return store.dispatch(deselectElement(id));
}
if (maxSeatSelectionCheck()) return;
return store.dispatch(selectElement(id));
} else {
const selectedTool = store.getState().toolbar.selectedTool;
Expand All @@ -82,6 +87,7 @@ export const Element: React.FC<IElementProps> = ({
}
return;
}
if (consumer.mode === "user" && maxSeatSelectionCheck()) return;
if (!ctrlPressed) {
store.dispatch(clearAndSelectElements([ref.current.id]));
} else {
Expand Down

0 comments on commit 6fe97ea

Please sign in to comment.