+
{typeof decl.icon === "string" ? : decl.icon}
);
diff --git a/frontend/app/hook/useLongClick.tsx b/frontend/app/hook/useLongClick.tsx
index 21de895b..5b71563f 100644
--- a/frontend/app/hook/useLongClick.tsx
+++ b/frontend/app/hook/useLongClick.tsx
@@ -3,7 +3,7 @@
import { useCallback, useEffect, useRef, useState } from "react";
-export const useLongClick = (ref, onClick, onLongClick, ms = 300) => {
+export const useLongClick = (ref, onClick, onLongClick, disabled = false, ms = 300) => {
const timerRef = useRef(null);
const [longClickTriggered, setLongClickTriggered] = useState(false);
@@ -40,7 +40,7 @@ export const useLongClick = (ref, onClick, onLongClick, ms = 300) => {
useEffect(() => {
const element = ref.current;
- if (!element) return;
+ if (!element || disabled) return;
element.addEventListener("mousedown", startPress);
element.addEventListener("mouseup", stopPress);
diff --git a/frontend/app/view/webview/webview.tsx b/frontend/app/view/webview/webview.tsx
index f07e1307..3bc0212a 100644
--- a/frontend/app/view/webview/webview.tsx
+++ b/frontend/app/view/webview/webview.tsx
@@ -63,15 +63,15 @@ export class WebViewModel implements ViewModel {
return [
{
elemtype: "iconbutton",
- className: this.shouldDisabledBackButton() ? "disabled" : "",
icon: "chevron-left",
click: this.handleBack.bind(this),
+ disabled: this.shouldDisabledBackButton(),
},
{
elemtype: "iconbutton",
- className: this.shouldDisabledForwardButton() ? "disabled" : "",
icon: "chevron-right",
click: this.handleForward.bind(this),
+ disabled: this.shouldDisabledForwardButton(),
},
{
elemtype: "div",
diff --git a/frontend/layout/lib/layoutModel.ts b/frontend/layout/lib/layoutModel.ts
index 1da6e39f..85663097 100644
--- a/frontend/layout/lib/layoutModel.ts
+++ b/frontend/layout/lib/layoutModel.ts
@@ -439,7 +439,6 @@ export class LayoutModel {
}
} else {
this.updateTree();
- this.setTreeStateAtom();
}
}
}
@@ -448,7 +447,7 @@ export class LayoutModel {
* Set the upstream tree state atom to the value of the local tree state.
* @param bumpGeneration Whether to bump the generation of the tree state before setting the atom.
*/
- setTreeStateAtom(bumpGeneration = true) {
+ setTreeStateAtom(bumpGeneration = false) {
if (bumpGeneration) {
this.treeState.generation++;
}
@@ -460,7 +459,7 @@ export class LayoutModel {
* This is a hack to ensure that when the updateTree first successfully runs, we set the upstream atom state to persist the initial leaf order.
* @see updateTree should be the only caller of this method.
*/
- setTreeStateAtomOnce = lazy(() => this.setTreeStateAtom());
+ setTreeStateAtomOnce = lazy(() => this.setTreeStateAtom(true));
/**
* Recursively walks the tree to find leaf nodes, update the resize handles, and compute additional properties for each node.
@@ -761,6 +760,7 @@ export class LayoutModel {
const isFocused = treeState.focusedNodeId === nodeid;
return isFocused;
}),
+ numLeafs: this.numLeafs,
isMagnified: atom((get) => {
const treeState = get(this.treeStateAtom);
return treeState.magnifiedNodeId === nodeid;
diff --git a/frontend/layout/lib/types.ts b/frontend/layout/lib/types.ts
index 5c1f45a3..7144a8d8 100644
--- a/frontend/layout/lib/types.ts
+++ b/frontend/layout/lib/types.ts
@@ -328,6 +328,7 @@ export interface NodeModel {
animationTimeS: number;
innerRect: Atom
;
blockNum: Atom;
+ numLeafs: Atom;
nodeId: string;
blockId: string;
isFocused: Atom;
diff --git a/frontend/types/custom.d.ts b/frontend/types/custom.d.ts
index 9e201f67..7c5a5bdd 100644
--- a/frontend/types/custom.d.ts
+++ b/frontend/types/custom.d.ts
@@ -154,6 +154,7 @@ declare global {
title?: string;
click?: (e: React.MouseEvent) => void;
longClick?: (e: React.MouseEvent) => void;
+ disabled?: boolean;
};
type HeaderTextButton = {