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

Account for presence of top banner when EuiDataGrid and Canvas are full screen #111038

Conversation

MichaelMarcialis
Copy link
Contributor

@MichaelMarcialis MichaelMarcialis commented Sep 2, 2021

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:

image

EuiDataGrid full screen after:

image

Canvas full screen before:

image

Canvas full screen after:

image

Closes #109554

Checklist

@MichaelMarcialis MichaelMarcialis added bug Fixes for quality problems that affect the customer experience Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:Discover Discover Application Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Feature:Canvas auto-backport Deprecated - use backport:version if exact versions are needed v7.15.0 v7.16.0 Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. labels Sep 2, 2021
@MichaelMarcialis MichaelMarcialis requested review from a team as code owners September 2, 2021 20:25
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@MichaelMarcialis MichaelMarcialis added impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort labels Sep 2, 2021
Comment on lines 107 to 110
const hasHeaderBanner = document.getElementsByClassName('kbnBody--hasHeaderBanner')
.length;

const headerBannerOffset = hasHeaderBanner ? HEADER_BANNER_HEIGHT : 0;
Copy link
Contributor

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.

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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

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;
Copy link
Contributor

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:

Suggested change
export const HEADER_BANNER_HEIGHT = 32;
export const HEADER_BANNER_HEIGHT = 32; // This value also declared in Sass file `.../path/to/_bases.css`

Copy link
Contributor Author

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.

Copy link
Contributor

@pgayvallet pgayvallet Sep 9, 2021

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

Copy link
Contributor Author

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.

Copy link
Contributor

@cchaos cchaos left a 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. 💯

Copy link
Contributor

@poffdeluxe poffdeluxe left a comment

Choose a reason for hiding this comment

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

Canvas changes LGTM

@MichaelMarcialis
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
canvas 1069 1071 +2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
canvas 1.6MB 1.6MB +1.2KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
canvas 29.9KB 30.1KB +229.0B
core 407.7KB 408.1KB +376.0B
total +605.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@MichaelMarcialis MichaelMarcialis merged commit 4dc7214 into elastic:master Sep 13, 2021
@MichaelMarcialis MichaelMarcialis deleted the 109554/top-banner-full-screen-fixes branch September 13, 2021 15:58
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Sep 13, 2021
…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]>
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Sep 13, 2021
…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]>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.15
7.x

The backport PRs will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Sep 13, 2021
…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]>
kibanamachine added a commit that referenced this pull request Sep 13, 2021
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed bug Fixes for quality problems that affect the customer experience Feature:Canvas Feature:Discover Discover Application impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v7.15.0 v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Top banners appear over data grids in full screen
7 participants