1
0

Clicking top bar scrolls to top of page

This commit is contained in:
Zef Hemel 2023-11-25 14:04:32 +01:00
parent 1ac494765f
commit aed8bef208
2 changed files with 10 additions and 1 deletions

View File

@ -30,6 +30,7 @@ export function TopBar({
progressPerc,
completer,
lhs,
onClick,
rhs,
}: {
pageName?: string;
@ -41,6 +42,7 @@ export function TopBar({
vimMode: boolean;
progressPerc?: number;
onRename: (newName?: string) => Promise<void>;
onClick: () => void;
completer: (context: CompletionContext) => Promise<CompletionResult | null>;
actionButtons: ActionButton[];
lhs?: ComponentChildren;
@ -77,7 +79,11 @@ export function TopBar({
}, []);
return (
<div id="sb-top" className={syncFailures > 1 ? "sb-sync-error" : undefined}>
<div
id="sb-top"
className={syncFailures > 1 ? "sb-sync-error" : undefined}
onClick={onClick}
>
{lhs}
<div className="main">
<div className="inner">

View File

@ -187,6 +187,9 @@ export class MainUI {
darkMode={viewState.uiOptions.darkMode}
progressPerc={viewState.progressPerc}
completer={editor.miniEditorComplete.bind(editor)}
onClick={() => {
editor.editorView.scrollDOM.scrollTop = 0;
}}
onRename={async (newName) => {
if (!newName) {
// Always move cursor to the start of the page