Skip to content

Commit 506f564

Browse files
Improve pane focus behavior: require item click, left-side note indicator
Focus now only changes when clicking an actual item in a pane, not the pane background. Note card active state uses a left-side bar instead of a full ring. Search input focus suppresses note highlight.
1 parent 31a1491 commit 506f564

4 files changed

Lines changed: 40 additions & 16 deletions

File tree

src/App.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
import { SidebarPane } from "@/features/shell/sidebar-pane";
2525
import { useRevealMainWindow } from "@/features/shell/use-reveal-main-window";
2626
import { useShellController } from "@/features/shell/use-shell-controller";
27-
import { useShellStore } from "@/stores/use-shell-store";
2827

2928
function App() {
3029
useTheme();
@@ -42,7 +41,6 @@ function App() {
4241
retryBootstrap,
4342
sidebarPaneProps,
4443
} = useShellController();
45-
const setFocusedPane = useShellStore((s) => s.setFocusedPane);
4644
const [commandPaletteOpen, setCommandPaletteOpen] = useState(false);
4745
useRevealMainWindow(!hasCompletedStartupReveal && !readyToRevealWindow);
4846

@@ -112,7 +110,6 @@ function App() {
112110
disableResponsive
113111
minSize={180}
114112
className="select-none"
115-
onClickCapture={() => setFocusedPane("sidebar")}
116113
>
117114
<SidebarPane {...sidebarPaneProps} />
118115
</Section>
@@ -128,7 +125,6 @@ function App() {
128125
maxSize={340}
129126
minSize={220}
130127
className="select-none"
131-
onMouseDown={() => setFocusedPane("notes")}
132128
>
133129
<NotesPane {...notesPaneProps} />
134130
</Section>
@@ -139,7 +135,7 @@ function App() {
139135
size={1}
140136
/>
141137

142-
<Section minSize={300} onMouseDown={() => setFocusedPane("editor")}>
138+
<Section minSize={300}>
143139
<EditorPane {...editorPaneProps} />
144140
</Section>
145141
</Container>

src/features/shell/editor-pane.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ export function EditorPane({
523523
onChange={onChange}
524524
onEditorFocusChange={(focused) => {
525525
if (focused) {
526+
setFocusedPane("editor");
526527
setHidePanelSearchInEditor(true);
527528
}
528529
}}

src/features/shell/notes-pane.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ export function NotesPane({
244244

245245
const shouldSkipAnimation = Date.now() < skipAnimationUntilRef.current;
246246
const searchInputRef = useRef<HTMLInputElement | null>(null);
247+
const [isSearchFocused, setIsSearchFocused] = useState(false);
247248
const scrollContainerRef = useRef<HTMLDivElement | null>(null);
248249
const { ref: loadMoreRef, inView } = useInView({
249250
rootMargin: "160px 0px",
@@ -427,9 +428,11 @@ export function NotesPane({
427428
<Search className="text-muted-foreground absolute top-1/2 left-3 size-4 -translate-y-1/2" />
428429
<input
429430
className="border-input/60 placeholder:text-muted-foreground focus:border-primary h-8 w-full rounded-md border bg-transparent py-1 pr-8 pl-9 text-sm outline-none"
431+
onBlur={() => setIsSearchFocused(false)}
430432
onChange={(event) =>
431433
setDraftSearchQuery(event.currentTarget.value)
432434
}
435+
onFocus={() => setIsSearchFocused(true)}
433436
onKeyDown={(event) => {
434437
if (event.key === "Escape") {
435438
if (draftSearchQuery) {
@@ -623,8 +626,10 @@ export function NotesPane({
623626
className={[
624627
"relative flex h-[6.75rem] w-full cursor-default flex-col items-start gap-2 overflow-hidden rounded-md px-3 py-2.5 text-left text-sm",
625628
isActive ? "bg-accent/50" : "",
626-
isActive && focusedPane === "notes"
627-
? "ring-primary/50 ring-2 ring-inset"
629+
isActive &&
630+
focusedPane === "notes" &&
631+
!isSearchFocused
632+
? "before:bg-primary/60 before:absolute before:inset-y-0 before:left-0 before:w-[5px]"
628633
: "",
629634
].join(" ")}
630635
onClick={() => onSelectNote(note.id)}

src/features/shell/use-shell-controller.ts

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export function useShellController() {
122122
const setNotebookFilter = useShellStore((state) => state.setNotebookFilter);
123123
const setSearchQuery = useShellStore((state) => state.setSearchQuery);
124124
const setSelectedNoteId = useShellStore((state) => state.setSelectedNoteId);
125+
const setFocusedPane = useShellStore((state) => state.setFocusedPane);
125126

126127
const sortViewKey =
127128
noteFilter === "notebook" ? (activeNotebookId ?? "all") : noteFilter;
@@ -1204,8 +1205,10 @@ export function useShellController() {
12041205
latestRef.current.handleRestoreNote(noteId),
12051206
onTrashNote: (noteId: string) =>
12061207
latestRef.current.handleTrashNote(noteId),
1207-
onSelectNote: (noteId: string) =>
1208-
latestRef.current.handleSelectNote(noteId),
1208+
onSelectNote: (noteId: string) => {
1209+
setFocusedPane("notes");
1210+
latestRef.current.handleSelectNote(noteId);
1211+
},
12091212
onSetNotePinned: (noteId: string, pinned: boolean) =>
12101213
latestRef.current.handleSetNotePinned(noteId, pinned),
12111214
searchQuery,
@@ -1227,6 +1230,7 @@ export function useShellController() {
12271230
notesQuery.hasNextPage,
12281231
notesQuery.isFetchingNextPage,
12291232
searchQuery,
1233+
setFocusedPane,
12301234
setNoteSortPrefs,
12311235
setSearchQuery,
12321236
sortViewKey,
@@ -1254,14 +1258,31 @@ export function useShellController() {
12541258
latestRef.current.handleDeleteNotebook(notebookId),
12551259
onHideCreateNotebook: hideCreateNotebook,
12561260
onHideRenameNotebook: hideRenameNotebook,
1257-
onSelectAll: () => latestRef.current.handleSelectAll(),
1258-
onSelectToday: () => latestRef.current.handleSelectToday(),
1259-
onSelectTodo: () => latestRef.current.handleSelectTodo(),
1260-
onSelectArchive: () => latestRef.current.handleSelectArchive(),
1261-
onSelectTrash: () => latestRef.current.handleSelectTrash(),
1261+
onSelectAll: () => {
1262+
setFocusedPane("sidebar");
1263+
latestRef.current.handleSelectAll();
1264+
},
1265+
onSelectToday: () => {
1266+
setFocusedPane("sidebar");
1267+
latestRef.current.handleSelectToday();
1268+
},
1269+
onSelectTodo: () => {
1270+
setFocusedPane("sidebar");
1271+
latestRef.current.handleSelectTodo();
1272+
},
1273+
onSelectArchive: () => {
1274+
setFocusedPane("sidebar");
1275+
latestRef.current.handleSelectArchive();
1276+
},
1277+
onSelectTrash: () => {
1278+
setFocusedPane("sidebar");
1279+
latestRef.current.handleSelectTrash();
1280+
},
12621281
onEmptyTrash: () => latestRef.current.handleEmptyTrash(),
1263-
onSelectNotebook: (notebookId: string) =>
1264-
latestRef.current.handleSelectNotebook(notebookId),
1282+
onSelectNotebook: (notebookId: string) => {
1283+
setFocusedPane("sidebar");
1284+
latestRef.current.handleSelectNotebook(notebookId);
1285+
},
12651286
onShowCreateNotebook: showCreateNotebook,
12661287
onShowRenameNotebook: (notebookId: string) =>
12671288
showRenameNotebook(notebookId, notebooks),
@@ -1287,6 +1308,7 @@ export function useShellController() {
12871308
notebooks,
12881309
renameNotebookMutation.isPending,
12891310
renamingNotebookName,
1311+
setFocusedPane,
12901312
setNewNotebookName,
12911313
setRenamingNotebookName,
12921314
showCreateNotebook,

0 commit comments

Comments
 (0)