From e369336c413a337e02afc027cc1aecdd76a496c5 Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 20 Jan 2021 23:36:16 -0500 Subject: fixed hiding AnchorMenu in text boxes. encapsulated fadeOut of AnchorMenu within class for simplicity. --- src/client/views/pdf/AnchorMenu.tsx | 11 ++++++++++- src/client/views/pdf/Annotation.tsx | 6 +++--- src/client/views/pdf/PDFViewer.tsx | 2 -- 3 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src/client/views/pdf') diff --git a/src/client/views/pdf/AnchorMenu.tsx b/src/client/views/pdf/AnchorMenu.tsx index e2bd5a73d..d1fdc6c44 100644 --- a/src/client/views/pdf/AnchorMenu.tsx +++ b/src/client/views/pdf/AnchorMenu.tsx @@ -1,7 +1,7 @@ import React = require("react"); import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Tooltip } from "@material-ui/core"; -import { action, computed, observable } from "mobx"; +import { action, computed, observable, IReactionDisposer, reaction } from "mobx"; import { observer } from "mobx-react"; import { ColorState } from "react-color"; import { Doc, Opt } from "../../../fields/Doc"; @@ -9,6 +9,7 @@ import { returnFalse, setupMoveUpEvents, unimplementedFunction, Utils } from ".. import { AntimodeMenu, AntimodeMenuProps } from "../AntimodeMenu"; import { ButtonDropdown } from "../nodes/formattedText/RichTextMenu"; import "./AnchorMenu.scss"; +import { SelectionManager } from "../../util/SelectionManager"; @observer export class AnchorMenu extends AntimodeMenu { @@ -58,6 +59,14 @@ export class AnchorMenu extends AntimodeMenu { AnchorMenu.Instance._canFade = false; } + _disposer: IReactionDisposer | undefined; + componentDidMount() { + this._disposer = reaction(() => SelectionManager.Views(), + selected => { + AnchorMenu.Instance.fadeOut(true); + }); + } + pointerDown = (e: React.PointerEvent) => { setupMoveUpEvents(this, e, (e: PointerEvent) => { this.StartDrag(e, this._commentCont.current!); diff --git a/src/client/views/pdf/Annotation.tsx b/src/client/views/pdf/Annotation.tsx index 85dd65901..cd32c2c3a 100644 --- a/src/client/views/pdf/Annotation.tsx +++ b/src/client/views/pdf/Annotation.tsx @@ -67,8 +67,8 @@ class RegionAnnotation extends React.Component { } componentWillUnmount() { - this._brushDisposer && this._brushDisposer(); - this._reactionDisposer && this._reactionDisposer(); + this._brushDisposer?.(); + this._reactionDisposer?.(); } @undoBatch @@ -83,8 +83,8 @@ class RegionAnnotation extends React.Component { DocListCast(group.annotations).forEach(anno => anno.delete = true); } - AnchorMenu.Instance.fadeOut(true); + this.props.select(false); } @undoBatch diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index f2052d454..fa97bde3f 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -137,7 +137,6 @@ export class PDFViewer extends ViewBoxAnnotatableComponent v.forEach(a => a.remove())); this._savedAnnotations.keys().forEach(k => this._savedAnnotations.setValue(k, [])); - AnchorMenu.Instance.fadeOut(true); } (SelectionManager.Views().length === 1) && this.setupPdfJsViewer(); }, @@ -389,7 +388,6 @@ export class PDFViewer extends ViewBoxAnnotatableComponent v.forEach(a => a.remove())); this._savedAnnotations.clear(); this._styleRule = addStyleSheetRule(PDFViewer._annotationStyle, "pdfAnnotation", { "pointer-events": "none" }); -- cgit v1.2.3-70-g09d2