aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/LinkDescriptionPopup.tsx
diff options
context:
space:
mode:
authorNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2024-05-05 18:28:35 -0400
committerNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2024-05-05 18:28:35 -0400
commit86f55d8aa12268fe847eaa344e8efbab5d293f34 (patch)
tree6bbc5c6fb6825ef969ed0342e4851667b81577cc /src/client/views/nodes/LinkDescriptionPopup.tsx
parent2a9db784a6e3492a8f7d8ce9a745b4f1a0494241 (diff)
parent139600ab7e8a82a31744cd3798247236cd5616fc (diff)
Merge branch 'nathan-starter' of https://github.com/brown-dash/Dash-Web into nathan-starter
Diffstat (limited to 'src/client/views/nodes/LinkDescriptionPopup.tsx')
-rw-r--r--src/client/views/nodes/LinkDescriptionPopup.tsx36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/client/views/nodes/LinkDescriptionPopup.tsx b/src/client/views/nodes/LinkDescriptionPopup.tsx
index 2a96ce458..ff95f8547 100644
--- a/src/client/views/nodes/LinkDescriptionPopup.tsx
+++ b/src/client/views/nodes/LinkDescriptionPopup.tsx
@@ -2,15 +2,17 @@ import { action, makeObservable, observable, reaction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { DocData } from '../../../fields/DocSymbols';
+import { StrCast } from '../../../fields/Types';
import { LinkManager } from '../../util/LinkManager';
import './LinkDescriptionPopup.scss';
import { TaskCompletionBox } from './TaskCompletedBox';
-import { StrCast } from '../../../fields/Types';
@observer
export class LinkDescriptionPopup extends React.Component<{}> {
+ // eslint-disable-next-line no-use-before-define
public static Instance: LinkDescriptionPopup;
@observable public display: boolean = false;
+ // eslint-disable-next-line react/no-unused-class-component-methods
@observable public showDescriptions: string = 'ON';
@observable public popupX: number = 700;
@observable public popupY: number = 350;
@@ -23,6 +25,20 @@ export class LinkDescriptionPopup extends React.Component<{}> {
LinkDescriptionPopup.Instance = this;
}
+ componentDidMount() {
+ document.addEventListener('pointerdown', this.onClick, true);
+ reaction(
+ () => this.display,
+ display => {
+ display && (this.description = StrCast(LinkManager.Instance.currentLink?.link_description));
+ }
+ );
+ }
+
+ componentWillUnmount() {
+ document.removeEventListener('pointerdown', this.onClick, true);
+ }
+
@action
descriptionChanged = (e: React.ChangeEvent<HTMLInputElement>) => {
this.description = e.currentTarget.value;
@@ -39,25 +55,13 @@ export class LinkDescriptionPopup extends React.Component<{}> {
@action
onClick = (e: PointerEvent) => {
- if (this.popupRef && !!!this.popupRef.current?.contains(e.target as any)) {
+ if (this.popupRef && !this.popupRef.current?.contains(e.target as any)) {
this.display = false;
this.description = '';
TaskCompletionBox.taskCompleted = false;
}
};
- componentDidMount() {
- document.addEventListener('pointerdown', this.onClick, true);
- reaction(
- () => this.display,
- display => display && (this.description = StrCast(LinkManager.Instance.currentLink?.link_description))
- );
- }
-
- componentWillUnmount() {
- document.removeEventListener('pointerdown', this.onClick, true);
- }
-
render() {
return !this.display ? null : (
<div
@@ -78,11 +82,11 @@ export class LinkDescriptionPopup extends React.Component<{}> {
onChange={e => this.descriptionChanged(e)}
/>
<div className="linkDescriptionPopup-btn">
- <div className="linkDescriptionPopup-btn-dismiss" onPointerDown={e => this.onDismiss(false)}>
+ <div className="linkDescriptionPopup-btn-dismiss" onPointerDown={() => this.onDismiss(false)}>
{' '}
Dismiss{' '}
</div>
- <div className="linkDescriptionPopup-btn-add" onPointerDown={e => this.onDismiss(true)}>
+ <div className="linkDescriptionPopup-btn-add" onPointerDown={() => this.onDismiss(true)}>
{' '}
Add{' '}
</div>