aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/SidebarAnnos.tsx
diff options
context:
space:
mode:
authorsharkiecodes <lanyi_stroud@brown.edu>2025-06-10 11:12:23 -0400
committersharkiecodes <lanyi_stroud@brown.edu>2025-06-10 11:12:23 -0400
commit272534c8a7517d08c70928c96d487d84b14772f6 (patch)
tree0e3e9a8cc83b8ba96b2bd49c9fc726b16411d60c /src/client/views/SidebarAnnos.tsx
parentc5981504058e0696827b4048fcd908a58fb0b0d3 (diff)
parentb91057d00512446339e48fb8488a97a1e5ef03d5 (diff)
Merge branch 'master' into lanyi-branch
Diffstat (limited to 'src/client/views/SidebarAnnos.tsx')
-rw-r--r--src/client/views/SidebarAnnos.tsx29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/client/views/SidebarAnnos.tsx b/src/client/views/SidebarAnnos.tsx
index 573c28ccf..71b479a22 100644
--- a/src/client/views/SidebarAnnos.tsx
+++ b/src/client/views/SidebarAnnos.tsx
@@ -3,7 +3,7 @@ import { observer } from 'mobx-react';
import * as React from 'react';
import { ClientUtils, returnFalse, returnOne, returnZero } from '../../ClientUtils';
import { emptyFunction } from '../../Utils';
-import { Doc, DocListCast, Field, FieldResult, FieldType, StrListCast } from '../../fields/Doc';
+import { Doc, DocListCast, Field, FieldResult, FieldType, Opt, StrListCast } from '../../fields/Doc';
import { Id } from '../../fields/FieldSymbols';
import { List } from '../../fields/List';
import { RichTextField } from '../../fields/RichTextField';
@@ -19,6 +19,7 @@ import { StyleProp } from './StyleProp';
import { CollectionStackingView } from './collections/CollectionStackingView';
import { DocumentView } from './nodes/DocumentView';
import { FieldViewProps } from './nodes/FieldView';
+import { FocusViewOptions } from './nodes/FocusViewOptions';
interface ExtraProps {
fieldKey: string;
@@ -149,15 +150,33 @@ export class SidebarAnnos extends ObservableReactComponent<FieldViewProps & Extr
};
makeDocUnfiltered = (doc: Doc) => {
if (DocListCast(this._props.Doc[this.sidebarKey]).find(anno => Doc.AreProtosEqual(doc.layout_unrendered ? DocCast(doc.annotationOn) : doc, anno))) {
- if (this.childFilters()) {
+ if (this.childFilters().length) {
// if any child filters exist, get rid of them
this._props.layoutDoc._childFilters = new List<string>();
+ return true;
}
- return true;
}
return false;
};
+ public static getView(sidebar: SidebarAnnos | null, sidebarShown: boolean, toggleSidebar: () => void, doc: Doc, options: FocusViewOptions) {
+ if (!sidebarShown) {
+ options.didMove = true;
+ toggleSidebar();
+ }
+ options.didMove = sidebar?.makeDocUnfiltered(doc) || options.didMove;
+
+ if (!doc.hidden) {
+ if (!options.didMove && options.toggleTarget) {
+ options.toggleTarget = false;
+ options.didMove = doc.hidden = true;
+ }
+ } else {
+ options.didMove = !(doc.hidden = false);
+ }
+ return new Promise<Opt<DocumentView>>(res => DocumentView.addViewRenderedCb(doc, res));
+ }
+
get sidebarKey() {
return this._props.fieldKey + '_sidebar';
}
@@ -181,8 +200,8 @@ export class SidebarAnnos extends ObservableReactComponent<FieldViewProps & Extr
layout_showTitle = () => 'title';
setHeightCallback = (height: number) => this._props.setHeight?.(height + this.filtersHeight());
sortByLinkAnchorY = (a: Doc, b: Doc) => {
- const ay = Doc.Links(a).length && DocCast(Doc.Links(a)[0].link_anchor_1).y;
- const by = Doc.Links(b).length && DocCast(Doc.Links(b)[0].link_anchor_1).y;
+ const ay = Doc.Links(a).length && DocCast(Doc.Links(a)[0].link_anchor_1)?.y;
+ const by = Doc.Links(b).length && DocCast(Doc.Links(b)[0].link_anchor_1)?.y;
return NumCast(ay) - NumCast(by);
};
render() {