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

Clear core loading indicator just before UI is rendered #55242

Merged
merged 2 commits into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions src/core/public/core_system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,15 +429,14 @@ describe('Notifications targetDomElement', () => {
rootDomElement,
});

let targetDomElementParentInStart: HTMLElement | null;
let targetDomElementInStart: HTMLElement | null;
MockNotificationsService.start.mockImplementation(({ targetDomElement }): any => {
expect(targetDomElement.parentElement).not.toBeNull();
targetDomElementParentInStart = targetDomElement.parentElement;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK it does not actually matter that the DOM element passed to Notifications is attached to the root element when NotificationsService#start is called, as long as it is attached at some point.

In the future, this pattern should probably be replaced by the single React-tree pattern provided by RenderingService that ChromeService and ApplicationService leverage.

targetDomElementInStart = targetDomElement;
});

// Starting the core system should pass the targetDomElement as a child of the rootDomElement
await core.setup();
await core.start();
expect(targetDomElementParentInStart!).toBe(rootDomElement);
expect(targetDomElementInStart!.parentElement).toBe(rootDomElement);
});
});
15 changes: 8 additions & 7 deletions src/core/public/core_system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,6 @@ export class CoreSystem {
const notificationsTargetDomElement = document.createElement('div');
const overlayTargetDomElement = document.createElement('div');

// ensure the rootDomElement is empty
this.rootDomElement.textContent = '';
this.rootDomElement.classList.add('coreSystemRootDomElement');
this.rootDomElement.appendChild(coreUiTargetDomElement);
this.rootDomElement.appendChild(notificationsTargetDomElement);
this.rootDomElement.appendChild(overlayTargetDomElement);

const overlays = this.overlay.start({
i18n,
targetDomElement: overlayTargetDomElement,
Expand Down Expand Up @@ -276,6 +269,14 @@ export class CoreSystem {
};

const plugins = await this.plugins.start(core);

// ensure the rootDomElement is empty
this.rootDomElement.textContent = '';
this.rootDomElement.classList.add('coreSystemRootDomElement');
this.rootDomElement.appendChild(coreUiTargetDomElement);
this.rootDomElement.appendChild(notificationsTargetDomElement);
this.rootDomElement.appendChild(overlayTargetDomElement);

const rendering = this.rendering.start({
application,
chrome,
Expand Down