diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2020-04-16 10:28:53 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2020-04-29 09:04:38 +0200 |
| commit | df7fdbba2cb3b014e9f91a51b7f1ac5ef5aff344 (patch) | |
| tree | 797a0abf0b1d9eacbd5e97acb455aca61a163f5b /gui/src/renderer/components | |
| parent | 013d54fc28480271758990cacc808a2f8950f52a (diff) | |
| download | mullvadvpn-df7fdbba2cb3b014e9f91a51b7f1ac5ef5aff344.tar.xz mullvadvpn-df7fdbba2cb3b014e9f91a51b7f1ac5ef5aff344.zip | |
Fix modal flickering
Diffstat (limited to 'gui/src/renderer/components')
| -rw-r--r-- | gui/src/renderer/components/Modal.tsx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gui/src/renderer/components/Modal.tsx b/gui/src/renderer/components/Modal.tsx index 287b5ae0a3..5a1db8f673 100644 --- a/gui/src/renderer/components/Modal.tsx +++ b/gui/src/renderer/components/Modal.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import ReactDOM from 'react-dom'; import { Component, Styles, Text, View } from 'reactxp'; import { colors } from '../../config.json'; +import { Scheduler } from '../../shared/scheduler'; import ImageView from './ImageView'; const MODAL_CONTAINER_ID = 'modalContainer'; @@ -108,18 +109,27 @@ interface IModalAlertProps { export class ModalAlert extends Component<IModalAlertProps> { private element = document.createElement('div'); private modalContainer?: Element; + private appendScheduler = new Scheduler(); public componentDidMount() { const modalContainer = document.getElementById(MODAL_CONTAINER_ID); if (modalContainer) { this.modalContainer = modalContainer; - modalContainer.appendChild(this.element); + + // 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); + }); } else { throw Error('Modal container not found when mounting modal'); } } public componentWillUnmount() { + this.appendScheduler.cancel(); + if (this.modalContainer) { this.modalContainer.removeChild(this.element); } |
