aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/LinkBox.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/LinkBox.tsx')
-rw-r--r--src/client/views/nodes/LinkBox.tsx15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/client/views/nodes/LinkBox.tsx b/src/client/views/nodes/LinkBox.tsx
index 8ebcefb35..b3245310f 100644
--- a/src/client/views/nodes/LinkBox.tsx
+++ b/src/client/views/nodes/LinkBox.tsx
@@ -39,14 +39,16 @@ export class LinkBox extends ViewBoxBaseComponent<FieldViewProps>() {
const anchor = anch?.layout_unrendered ? DocCast(anch.annotationOn) : anch;
return DocumentManager.Instance.getDocumentView(anchor, this.DocumentView?.().containerViewPath?.().lastElement());
};
+ _hackToSeeIfDeleted: any;
componentWillUnmount() {
+ this._hackToSeeIfDeleted && clearTimeout(this._hackToSeeIfDeleted);
Object.keys(this._disposers).forEach(key => this._disposers[key]());
}
componentDidMount() {
this._props.setContentViewBox?.(this);
this._disposers.deleting = reaction(
() => !this.anchor1 || !this.anchor2,
- empty => empty && this._props.removeDocument?.(this.Document)
+ empty => empty && (this._hackToSeeIfDeleted = setTimeout(() => this._props.removeDocument?.(this.Document), 1000))
);
this._disposers.dragging = reaction(
() => ({ drag: SnappingManager.IsDragging }),
@@ -100,8 +102,10 @@ export class LinkBox extends ViewBoxBaseComponent<FieldViewProps>() {
var foundParent = false;
const getAnchor = (field: FieldResult): Element[] => {
- const doc = DocCast(field);
+ const docField = DocCast(field);
+ const doc = docField?.layout_unrendered ? DocCast(docField.annotationOn, docField) : docField;
const ele = document.getElementById(doc[Id]);
+ if (ele?.className === 'linkBox-label') foundParent = true;
if (ele?.getBoundingClientRect().width) return [ele];
const eles = Array.from(document.getElementsByClassName(doc[Id])).filter(ele => ele?.getBoundingClientRect().width);
const annoOn = DocCast(doc.annotationOn);
@@ -124,7 +128,10 @@ export class LinkBox extends ViewBoxBaseComponent<FieldViewProps>() {
return null;
}
if (foundParent) {
- setTimeout(action(() => (this._forceAnimate = this._forceAnimate + 1)));
+ setTimeout(
+ action(() => (this._forceAnimate = this._forceAnimate + 0.01)),
+ 1
+ );
}
if (at || bt) setTimeout(action(() => (this._forceAnimate = this._forceAnimate + 0.01))); // this forces an update during a transition animation
@@ -171,6 +178,8 @@ export class LinkBox extends ViewBoxBaseComponent<FieldViewProps>() {
color={color}
labels={
<div
+ id={this.Document[Id]}
+ className={'linkBox-label'}
style={{
borderRadius: '8px',
pointerEvents: this._props.isDocumentActive?.() ? 'all' : undefined,