Skip to content

Conversation

georgylobko
Copy link
Member

Description

Added a new whenAppLayoutReady to the plugin api to keep track of AppLayout state loading. It's useful when left drawer needs to be updated - in this case making sure that AppLayout has already loaded is necessary.

Related links, issue #, if available: n/a

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

codecov bot commented Sep 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.22%. Comparing base (d1c8b7f) to head (c8d86f2).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3863   +/-   ##
=======================================
  Coverage   97.22%   97.22%           
=======================================
  Files         844      844           
  Lines       24586    24595    +9     
  Branches     8672     8677    +5     
=======================================
+ Hits        23904    23913    +9     
+ Misses        675      633   -42     
- Partials        7       49   +42     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@georgylobko georgylobko marked this pull request as ready for review September 15, 2025 14:59
@georgylobko georgylobko requested a review from a team as a code owner September 15, 2025 14:59
@georgylobko georgylobko requested review from just-boris and removed request for a team September 15, 2025 14:59
* Returns a promise that resolves once the app layout has loaded
*/
export function whenAppLayoutReady() {
return appLayoutReadyDefer.promise;
Copy link
Member

Choose a reason for hiding this comment

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

  1. This code does not work, because the remove widget and the app layout widget are separate bundles, so they will refer to a different appLayoutReadyDefer instance

  2. What is going to happen if app layout renders and then unmounts? This code resolves the promise instantly, but there is no app layout on the page

  3. What happens if app layout never renders? The promise will hang forever in this case. We should mention to the consuming team that they might want to add some timeout on their end, for example: Promise.race([whenAppLayoutReady(), timeout(3000)])

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. Addressed. Now this promise is stored in window object, so any instance will have access to it
  2. The purpose of this promise is to be resolved as soon as the app layout is available, it's not designed to handle other use cases such as unmounting. Do you have any suggestions on that?
  3. Point taken

Copy link
Member

@just-boris just-boris Sep 16, 2025

Choose a reason for hiding this comment

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

  1. Reverse the control.
export function whenAppLayoutReady() {
   if(isAppLayoutReady()) {
        return Promise.resolve();
   }
   return new Promise((resolve) => appLayoutReadyCallbacks.push(resolve));
}

function registerAppLayoutHandler () {
   appLayoutReadyCallbacks.forEach(() => cb());
   appLayoutReadyCallbacks = [];

    // other code...
}

Copy link
Member

@just-boris just-boris left a comment

Choose a reason for hiding this comment

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

See this thread #3863 (comment)

just-boris
just-boris previously approved these changes Sep 16, 2025
}
const win = getWindow();
win[storageKeyReadyDeferCallbacks] = win[storageKeyReadyDeferCallbacks] ?? [];
const defer = new Defer();
Copy link
Member

Choose a reason for hiding this comment

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

You do not need to introduce the defer helper any more. The code from my previous comment works without it

@georgylobko georgylobko force-pushed the feat/when-app-layout-ready branch from 789e5b4 to c8d86f2 Compare September 16, 2025 12:52
@georgylobko georgylobko added this pull request to the merge queue Sep 16, 2025
Merged via the queue into main with commit 7ee756d Sep 16, 2025
38 checks passed
@georgylobko georgylobko deleted the feat/when-app-layout-ready branch September 16, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants