-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[SharedUX] Fix issue with services package; fix ExitFullScreenButton
#127988
Conversation
packages/kbn-shared-ux-components/src/exit_full_screen_button/exit_full_screen_button.tsx
Outdated
Show resolved
Hide resolved
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Module Count
Public APIs missing exports
Page load bundle
History
To update your PR or re-run it, just comment with: |
|
||
// ...wrap React content with the context.. | ||
} | ||
``` | ||
|
||
## Use in Kibana plugins | ||
|
||
In order to make consumption of these services easy by Kibana plugins, `src/plugins/shared_ux` provides a pre-wired `SharedUxServicesProvider` component as part of the `start` lifecycle. Plugins can simply make `sharedUX` a dependency and wrap their solution root or any component. See the documentation for `sharedUX` for more details. | ||
In order to make consumption of these services easy by Kibana plugins, `src/plugins/shared_ux` provides a pre-wired set of services as part of the `start` lifecycle. Plugins can simply make `sharedUX` a dependency, import `SharedUsServicesProvider` and wrap their solution root (or any component). See the documentation for `sharedUX` for more details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found small typo 😄 SharedUsServicesProvider
Summary
This was a fun one.
First, @maksimkovalev and @nreese noticed a bug with
ExitFullScreenButton
where, when opting totoggleChrome
, the chrome wasn't being hidden on mount. So this PR fixes that issue for #126055.Second, with the recent changes to Shared UX to make it package-based, (#127546) the service context provided by
src/plugins/shared_ux
has stopped working inx-pack/plugins/maps
.Problem
Digging in, there was a lot of weirdness. A component wrapped with the context within the SharedUX plugin had access to the configured services. But a dependent plugin had a
null
context.I messed with it for a few hours and was really starting to doubt my sanity. Talking it through with @spalger this morning, he supplied the answer:
Each plugin that imports a package gets its own copy of that package. That meant Shared UX and Maps were both importing their own copies of the hooks, but those hooks were referencing their own copy of the context.
As a result, providing a wired context as a part of the
start
contract of the Shared UX plugin meant only the hooks within Shared UX would be referencing the correct Context.Solution
We have to tweak the API a bit. The Shared UX plugin can provide the configured services as a part of its
start
contract, but each plugin needs to provide those services to its local version of theSharedUxContextProvider
: