Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: improve shift + click selection

thecodrr7ef2d602977a
diff --git a/apps/web/src/components/list-container/index.js b/apps/web/src/components/list-container/index.js
index b45935460..fabefc4f2 100644
--- a/apps/web/src/components/list-container/index.js
+++ b/apps/web/src/components/list-container/index.js
@@ -21,7 +21,6 @@ function ListContainer(props) {
const setSelectedItems = useSelectionStore((store) => store.setSelectedItems);
const listRef = useRef();
const focusedItemIndex = useRef(-1);
- const anchorIndex = useRef();
const listContainerRef = useRef();
const groups = useMemo(
() => props.items.filter((v) => v.type === "header"),
@@ -48,9 +47,6 @@ function ListContainer(props) {
focusedItemIndex.current = parseInt(
e.target.parentElement.dataset.index
);
-
- if (selectionStore.get().selectedItems < 2)
- anchorIndex.current = focusedItemIndex.current;
}
}}
>
@@ -66,7 +62,11 @@ function ListContainer(props) {
e.preventDefault();
const endIndex = parseInt(listItem.dataset.index);
if (isNaN(endIndex)) return;
- setSelectedItems(items.slice(anchorIndex, endIndex + 1));
+ setSelectedItems([
+ ...selectionStore.get().selectedItems,
+ ...items.slice(focusedItemIndex.current, endIndex + 1),
+ ]);
+ listItem.firstElementChild.focus();
}
}}
onKeyDown={(e) => {