-
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
Account for presence of top banner when EuiDataGrid and Canvas are full screen #111038
Account for presence of top banner when EuiDataGrid and Canvas are full screen #111038
Conversation
Pinging @elastic/kibana-core (Team:Core) |
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
const hasHeaderBanner = document.getElementsByClassName('kbnBody--hasHeaderBanner') | ||
.length; | ||
|
||
const headerBannerOffset = hasHeaderBanner ? HEADER_BANNER_HEIGHT : 0; |
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.
Sorry, when you asked me how to check if a banner was present in javascript, I thought it was for testing, not for actually using it in a plugin's code.
The proper way with Kibana API would be to add a new hasHeaderBanner
API, and have the plugin leverage this info.
kibana/src/core/public/chrome/chrome_service.tsx
Lines 272 to 274 in e88d77b
setHeaderBanner: (headerBanner?: ChromeUserBanner) => { | |
headerBanner$.next(headerBanner); | |
}, |
Something like
hasHeaderBanner$: () => {
return headerBanner$.pipe(map((banner) => banner !== undefined))
},
How urgent is this? I could have a PR ready tomorrow to add the API to coreStart.chrome
. Not sure how hard to would be to cascade this info from canvas
mountpoint to this component?
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.
Thanks for the help! Not super urgent in my opinion. Just let me know what I'd need to do on my end when you're ready.
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.
I created #111248, I'll ping you once it's merged.
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.
#111248 has been merged and backported to 7.16
and 7.15
. You should now be able to use the coreStart.chrome.hasHeaderBanner$
API.
Now, about how to retrieve this API down in the Workpad
component. I took a quick look, but given the multiple layers of composition of the component (e.g x-pack/plugins/canvas/public/components/workpad/index.js
) and the fact that it's still plain javascript, I'm not comfortable performing the change myself in your PR, and think that maybe the owner team should be the one to do it.
I see the canvas
app is wrapping their root tree with the Kibana
context provider
kibana/x-pack/plugins/canvas/public/application.tsx
Lines 73 to 74 in 303526f
ReactDOM.render( | |
<KibanaContextProvider services={{ ...startPlugins, ...coreStart }}> |
So in theory the chrome
core service should be accessible at any depth, using either the useKibana
hook or the withKibana
HOC.
So, it may be as easy as using the HOC in x-pack/plugins/canvas/public/components/workpad/workpad.js
, however I'm not sure about the best practices, like maybe the team prefers to add this wrapper in the composition performed in x-pack/plugins/canvas/public/components/workpad/index.js
, or even from elsewhere.
cc @elastic/kibana-presentation I think we need your help here.
@@ -45,3 +45,4 @@ export const CANVAS_EMBEDDABLE_CLASSNAME = `canvasEmbeddable`; | |||
export const CONTEXT_MENU_TOP_BORDER_CLASSNAME = 'canvasContextMenu--topBorder'; | |||
export const API_ROUTE_FUNCTIONS = `${API_ROUTE}/fns`; | |||
export const ESSQL_SEARCH_STRATEGY = 'essql'; | |||
export const HEADER_BANNER_HEIGHT = 32; |
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.
Suggestion: This is number can easily get out sync between the JS and Sass versions. I'd highly suggest moving it a constant that lives within the actual banner service and imported by Canvas. Then in both places (JS & CSS), add a comment that mentions where it's counterpart lives. Something like:
export const HEADER_BANNER_HEIGHT = 32; | |
export const HEADER_BANNER_HEIGHT = 32; // This value also declared in Sass file `.../path/to/_bases.css` |
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.
@pgayvallet: Thoughts on Caroline's suggestion above to move the banner height to live in the banner service? Sounds good to me, but would likely need your guidance on how best to implement.
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.
It definitely makes sense, but I think this can be done by my team as a follow-up (if that's fine with you). I created #111688
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.
Sounds good. In the mean time, I'll add those suggested comments in the current variable locations.
Use hasHeaderBanner$
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.
Code LGTM, sorry I didn't pull down to test locally, but I trust your screenshots. Thanks for taking care of this one from EUI to here. 💯
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.
Canvas changes LGTM
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
…ll screen (elastic#111038) * account for banners when data grid is full screen * account for banner when canvas is full screen * change height per feedback * add withKibana * rm withKibana; move vars out of Fullscreen * Use hasHeaderBanner$ * add banner height var comments * fix ts error Co-authored-by: Catherine Liu <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
…ll screen (elastic#111038) * account for banners when data grid is full screen * account for banner when canvas is full screen * change height per feedback * add withKibana * rm withKibana; move vars out of Fullscreen * Use hasHeaderBanner$ * add banner height var comments * fix ts error Co-authored-by: Catherine Liu <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
…ll screen (#111038) (#111981) * account for banners when data grid is full screen * account for banner when canvas is full screen * change height per feedback * add withKibana * rm withKibana; move vars out of Fullscreen * Use hasHeaderBanner$ * add banner height var comments * fix ts error Co-authored-by: Catherine Liu <[email protected]> Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Michael Marcialis <[email protected]> Co-authored-by: Catherine Liu <[email protected]>
…ll screen (#111038) (#111980) * account for banners when data grid is full screen * account for banner when canvas is full screen * change height per feedback * add withKibana * rm withKibana; move vars out of Fullscreen * Use hasHeaderBanner$ * add banner height var comments * fix ts error Co-authored-by: Catherine Liu <[email protected]> Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Michael Marcialis <[email protected]> Co-authored-by: Catherine Liu <[email protected]>
Summary
This PR makes style changes to correctly account for the presence of a Kibana top banner when either the
EuiDataGrid
component or the Canvas app are in full screen mode. Previously, the contents of these full screen items would fall behind and become hidden under the top banner. Some notes regarding these two changes:Use of
.euiDataGrid--fullScreen
selector: I know using EUI classes in Kibana stylesheets is frowned upon, but I didn't know of any other way that we could apply these top banner offset styles globally to the component. If there is a better way to do it, please let me know. CCing @cchaos.Canvas conditional styles: Canvas appears to have a fairly robust set of custom styles, and I didn't want to go too far down the rabbit hole of suggesting too many changes. As such, I've made a small handful of conditional changes to the scaling and positioning styles when in full screen mode and a top banner is present. If what I've done feels a little too hacky, please let me know and I'd be happy to tweak as necessary. CCing @elastic/kibana-presentation.
EuiDataGrid
full screen before:EuiDataGrid
full screen after:Canvas full screen before:
Canvas full screen after:
Closes #109554
Checklist