summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer/components
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2021-02-07 20:37:10 +0100
committerOskar Nyberg <oskar@mullvad.net>2021-02-07 20:37:10 +0100
commitd0562cb349a8e73a417711f7c489aaffdf7efe21 (patch)
treeab98753dbddf460cbbe65a92836120626a0deeec /gui/src/renderer/components
parent1a76971c57bccdf80477507608d2038a1909b373 (diff)
downloadmullvadvpn-d0562cb349a8e73a417711f7c489aaffdf7efe21.tar.xz
mullvadvpn-d0562cb349a8e73a417711f7c489aaffdf7efe21.zip
Remove delay when appending modal to modal container
Diffstat (limited to 'gui/src/renderer/components')
-rw-r--r--gui/src/renderer/components/Modal.tsx13
1 files changed, 2 insertions, 11 deletions
diff --git a/gui/src/renderer/components/Modal.tsx b/gui/src/renderer/components/Modal.tsx
index 01a2bba321..49f0793f5d 100644
--- a/gui/src/renderer/components/Modal.tsx
+++ b/gui/src/renderer/components/Modal.tsx
@@ -3,7 +3,6 @@ import ReactDOM from 'react-dom';
import styled from 'styled-components';
import { colors } from '../../config.json';
import log from '../../shared/logging';
-import { Scheduler } from '../../shared/scheduler';
import ImageView from './ImageView';
const MODAL_CONTAINER_ID = 'modal-container';
@@ -137,7 +136,6 @@ export function ModalAlert(props: IModalAlertProps) {
class ModalAlertWithContext extends React.Component<IModalAlertProps & IModalContext> {
private element = document.createElement('div');
private modalRef = React.createRef<HTMLDivElement>();
- private appendScheduler = new Scheduler();
constructor(props: IModalAlertProps & IModalContext) {
super(props);
@@ -155,13 +153,8 @@ class ModalAlertWithContext extends React.Component<IModalAlertProps & IModalCon
const modalContainer = document.getElementById(MODAL_CONTAINER_ID);
if (modalContainer) {
- // Mounting the container element immediately results in a graphical issue with the dialog
- // first rendering with the wrong proportions and then changing to the correct proportions.
- // Postponing it to the next event cycle solves this issue.
- this.appendScheduler.schedule(() => {
- modalContainer.appendChild(this.element);
- this.modalRef.current?.focus();
- });
+ modalContainer.appendChild(this.element);
+ this.modalRef.current?.focus();
} else {
log.error('Modal container not found when mounting modal');
}
@@ -171,8 +164,6 @@ class ModalAlertWithContext extends React.Component<IModalAlertProps & IModalCon
this.props.setActiveModal(false);
document.removeEventListener('keydown', this.handleKeyPress, true);
- this.appendScheduler.cancel();
-
const modalContainer = document.getElementById(MODAL_CONTAINER_ID);
modalContainer?.removeChild(this.element);
}