Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid deleting the HTML node when destroying ViewWrapper instance and set visible state correctly #337

Merged
merged 3 commits into from
Jun 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/base/ViewWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,19 @@ export default class ViewWrapper extends EventHandler implements IViewProvider {

set visible(visible: boolean) {
const selection = this.inputSelections.get(DEFAULT_SELECTION_NAME);
if (visible && this.instance == null && selection && this.match(selection)) {
//lazy init
this.createView(selection);
}

if (visible) {
this.node.classList.remove('hidden');
this.update();
} else {
this.node.classList.add('hidden');
}

if (visible && this.instance == null && selection && this.match(selection)) {
//lazy init
this.createView(selection);
} else {
this.update(); // if the view was just created we don't need to call update again
}
}

get visible() {
Expand Down Expand Up @@ -339,8 +342,8 @@ export default class ViewWrapper extends EventHandler implements IViewProvider {
}

update() {
if (this.visible && this.instance && typeof (<any>this.instance).update === 'function' && this.node.getBoundingClientRect().width > 0) {
(<any>this.instance!).update();
if (this.visible && this.instance && typeof (<any>this.instance).forceUpdate === 'function') {
(<any>this.instance!).forceUpdate();
}
}

Expand Down