[Core System Flyout Service] Subscribe to CLOSE_SESSION events for cascade close#251146
Conversation
|
|
||
| import React from 'react'; | ||
|
|
||
| import { EuiCode, EuiPageTemplate, EuiText, type EuiPageTemplateProps } from '@elastic/eui'; |
There was a problem hiding this comment.
example plugin has been updated to demo a cascading-close bug
4b85f14 to
dfc2527
Compare
dfc2527 to
d0c3a9f
Compare
|
Unblocked by #252315 |
5c5d7cc to
ee0a7c7
Compare
| constructor(container: HTMLElement) { | ||
| this.container = container; | ||
| this.onClose = this.closeSubject.toPromise(); | ||
| this.onClose = firstValueFrom(this.closeSubject); |
There was a problem hiding this comment.
The firstValueFrom is an unrelated deprecated code cleanup
There was a problem hiding this comment.
nit: if you want to avoid errors thrown if closeSubject closes the observable before emitting, you can specify a fallback value as a 2nd parameter to firstValueFrom.
| constructor(container: HTMLElement) { | ||
| this.container = container; | ||
| this.onClose = this.closeSubject.toPromise(); | ||
| this.onClose = firstValueFrom(this.closeSubject); |
There was a problem hiding this comment.
nit: if you want to avoid errors thrown if closeSubject closes the observable before emitting, you can specify a fallback value as a 2nd parameter to firstValueFrom.
|
Hey @tsullivan, is there anything blocking the merge? |
💔 Build Failed
Failed CI StepsTest Failures
Metrics [docs]Page load bundle
History
|
…scade close (elastic#251146) ## Summary Depends on elastic/eui#9347 Closes: elastic/kibana-team#2725 This PR updates Kibana’s `SystemFlyoutService` to listen to the EUI flyout manager’s `CLOSE_SESSION` events and close imperative flyout roots when their session is removed. This makes cascade-close work for `openSystemFlyout()` flows that render in separate React roots. The flyout system example is adjusted to stop manually closing child refs so it reflects system behavior. **Key changes** - Subscribe to `getFlyoutManagerStore().subscribeToEvents` and close matching flyouts on `CLOSE_SESSION`. - Make `SystemFlyoutRef.isClosed` a getter backed by a private flag. - Remove manual child close from the flyout system example. **Notes** - Depends on EUI export of `subscribeToEvents` and `CLOSE_SESSION` events (see EUI PR elastic/eui#9347). ### Testing 1. Run Kibana from source locally with example plugins ``` yarn start --run-examples ``` 2. Navigate to `http://localhost:5601/app/flyoutSystemExamples` 3. Make sure the child flyout is automatically closed when testing the `Session X` flyout, as shown in the following screen recording. https://github.com/user-attachments/assets/d645b9a0-1ad7-45e2-8966-35da03b0c341 ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - ~~[ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)~~ - ~~[ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials~~ - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - ~~[ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list]~~(https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - ~~[ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations.~~ - ~~[ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed~~ - ~~[ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)~~ - ~~[ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels.~~ ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. None
…scade close (elastic#251146) ## Summary Depends on elastic/eui#9347 Closes: elastic/kibana-team#2725 This PR updates Kibana’s `SystemFlyoutService` to listen to the EUI flyout manager’s `CLOSE_SESSION` events and close imperative flyout roots when their session is removed. This makes cascade-close work for `openSystemFlyout()` flows that render in separate React roots. The flyout system example is adjusted to stop manually closing child refs so it reflects system behavior. **Key changes** - Subscribe to `getFlyoutManagerStore().subscribeToEvents` and close matching flyouts on `CLOSE_SESSION`. - Make `SystemFlyoutRef.isClosed` a getter backed by a private flag. - Remove manual child close from the flyout system example. **Notes** - Depends on EUI export of `subscribeToEvents` and `CLOSE_SESSION` events (see EUI PR elastic/eui#9347). ### Testing 1. Run Kibana from source locally with example plugins ``` yarn start --run-examples ``` 2. Navigate to `http://localhost:5601/app/flyoutSystemExamples` 3. Make sure the child flyout is automatically closed when testing the `Session X` flyout, as shown in the following screen recording. https://github.com/user-attachments/assets/d645b9a0-1ad7-45e2-8966-35da03b0c341 ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - ~~[ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)~~ - ~~[ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials~~ - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - ~~[ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list]~~(https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - ~~[ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations.~~ - ~~[ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed~~ - ~~[ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)~~ - ~~[ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels.~~ ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. None
Summary
Depends on elastic/eui#9347
Closes: https://github.com/elastic/kibana-team/issues/2725
This PR updates Kibana’s
SystemFlyoutServiceto listen to the EUI flyout manager’sCLOSE_SESSIONevents and close imperative flyout roots when their session is removed. This makes cascade-close work foropenSystemFlyout()flows that render in separate React roots. The flyout system example is adjusted to stop manually closing child refs so it reflects system behavior.Key changes
getFlyoutManagerStore().subscribeToEventsand close matching flyouts onCLOSE_SESSION.SystemFlyoutRef.isCloseda getter backed by a private flag.Notes
subscribeToEventsandCLOSE_SESSIONevents (see EUI PR [Flyout System] export flyout manager store for read-only subscription eui#9347).Testing
http://localhost:5601/app/flyoutSystemExamplesSession Xflyout, as shown in the following screen recording.overlays-service-child-flyout-close-automatically.mov
Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
[ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support[ ] Documentation was added for features that require explanation or tutorials[ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)[ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. Therelease_note:breakinglabel should be applied in these situations.[ ] Flaky Test Runner was used on any tests changed[ ] The PR description includes the appropriate Release Notes section, and the correctrelease_note:*label is applied per the guidelines[ ] Review the backport guidelines and apply applicablebackport:*labels.Identify risks
Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss.
None