diff --git a/specifyweb/frontend/js_src/lib/components/WorkBench/hooks.ts b/specifyweb/frontend/js_src/lib/components/WorkBench/hooks.ts index f7a65ef8f25..bf36365d31a 100644 --- a/specifyweb/frontend/js_src/lib/components/WorkBench/hooks.ts +++ b/specifyweb/frontend/js_src/lib/components/WorkBench/hooks.ts @@ -568,6 +568,21 @@ export function getHotHooks(wbView: WbView) { 10 ); }, + + /* + * Disallow user from selecting several times the same cell + */ + afterSelection: () => { + if (wbView.hot === undefined) return; + const selection = wbView.hot?.getSelected() ?? []; + const newSelection = f + .unique(selection.map((row) => JSON.stringify(row))) + .map((row) => JSON.parse(row)); + if (newSelection.length !== selection.length) { + wbView.hot?.deselectCell(); + wbView.hot?.selectCells(newSelection); + } + }, }); }