Skip to content

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

feat: select group items if ctrl+clicked on group header

thecodrr722b2add940f
diff --git a/apps/web/src/components/group-header/index.js b/apps/web/src/components/group-header/index.js
index cfa2ec623..d52537257 100644
--- a/apps/web/src/components/group-header/index.js
+++ b/apps/web/src/components/group-header/index.js
@@ -129,7 +129,7 @@ function map(items) {
}
function GroupHeader(props) {
- const { title, groups, onJump, index, type, refresh } = props;
+ const { title, groups, onJump, index, type, refresh, onSelectGroup } = props;
const [groupOptions, setGroupOptions] = useState(
db.settings.getGroupOptions(type)
);
@@ -160,6 +160,10 @@ function GroupHeader(props) {
<AnimatedFlex
transition={{ duration: 0.3, repeatType: "reverse", repeat: 3 }}
onClick={(e) => {
+ if (e.ctrlKey) {
+ onSelectGroup();
+ return;
+ }
if (groups.length <= 0) return;
e.stopPropagation();
const items = groups.map((group) => ({
diff --git a/apps/web/src/components/list-container/index.js b/apps/web/src/components/list-container/index.js
index 74de8fe14..9e66158c2 100644
--- a/apps/web/src/components/list-container/index.js
+++ b/apps/web/src/components/list-container/index.js
@@ -22,6 +22,10 @@ function ListContainer(props) {
const listRef = useRef();
const focusedItemIndex = useRef(-1);
const listContainerRef = useRef();
+ const groups = useMemo(
+ () => props.items.filter((v) => v.type === "header"),
+ [props.items]
+ );
return (
<Flex variant="columnFill">
@@ -127,7 +131,23 @@ function ListContainer(props) {
refresh={refresh}
title={item.title}
index={index}
- groups={props.items.filter((v) => v.type === "header")}
+ onSelectGroup={() => {
+ let endIndex;
+ for (let i = index + 1; i < props.items.length; ++i) {
+ if (props.items[i].type === "header") {
+ endIndex = i;
+ break;
+ }
+ }
+ setSelectedItems([
+ ...selectionStore.get().selectedItems,
+ ...props.items.slice(
+ index,
+ endIndex || props.items.length
+ ),
+ ]);
+ }}
+ groups={groups}
onJump={(title) => {
const index = props.items.findIndex(
(v) => v.title === title