-
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
[Serverless Nav] Fix issues with sticky app menu subheader #168372
Changes from 5 commits
e06aeb3
bdf5f47
b43361d
8017506
0a2a694
d8c2ebb
fa1f9d7
895c3dc
4e866a7
9fc3c18
39d62e2
fa6ed91
0153c56
50c30f6
72f6748
96c8d19
bf2389f
6b45ad9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
@mixin kibanaFullBodyHeight($additionalOffset: 0) { | ||
// The `--euiFixedHeadersOffset` CSS variable is automatically updated by | ||
// The `--kbnAppHeadersOffset` CSS variable is automatically updated by | ||
// styles/rendering/_base.scss, based on whether the Kibana chrome has a | ||
// header banner, and is visible or hidden | ||
height: calc(100vh - var(--euiFixedHeadersOffset, 0) - #{$additionalOffset}); | ||
// header banner, app menu, and is visible or hidden | ||
height: calc(100vh - var(--kbnAppHeadersOffset, 0) - #{$additionalOffset}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes double scroll in serverless discover caused by incorrect app container height |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,14 +138,19 @@ export function TopNavMenu<QT extends AggregateQuery | Query = Query>( | |
'kbnTopNavMenu__wrapper--hidden': visible === false, | ||
}); | ||
if (setMenuMountPoint) { | ||
const badgesEl = renderBadges(); | ||
const menuEl = renderMenu(menuClassName); | ||
return ( | ||
<> | ||
<MountPointPortal setMountPoint={setMenuMountPoint}> | ||
<span className={`${wrapperClassName} kbnTopNavMenu__badgeWrapper`}> | ||
{renderBadges()} | ||
{renderMenu(menuClassName)} | ||
</span> | ||
</MountPointPortal> | ||
{(badgesEl || menuEl) && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes empty app header for top_nav component, for example, discover doc page: |
||
<UnmountableMountPointPortal setMountPoint={setMenuMountPoint}> | ||
<span className={`${wrapperClassName} kbnTopNavMenu__badgeWrapper`}> | ||
{badgesEl} | ||
{menuEl} | ||
</span> | ||
</UnmountableMountPointPortal> | ||
)} | ||
|
||
{renderSearchBar()} | ||
</> | ||
); | ||
|
@@ -169,3 +174,16 @@ TopNavMenu.defaultProps = { | |
showFilterBar: true, | ||
screenTitle: '', | ||
}; | ||
|
||
// TODO: make this a part of @kbn/react-kibana-mount ? | ||
const UnmountableMountPointPortal: React.FC<{ | ||
setMountPoint: (menuMount: MountPoint | undefined) => void; | ||
}> = ({ setMountPoint, children }) => { | ||
React.useEffect(() => { | ||
return () => { | ||
setMountPoint(undefined); | ||
}; | ||
}, [setMountPoint]); | ||
|
||
return <MountPointPortal setMountPoint={setMountPoint}>{children}</MountPointPortal>; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,30 +7,43 @@ | |
|
||
import { EuiButton } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { HeaderMenuPortal } from '@kbn/observability-shared-plugin/public'; | ||
import { AppMountParameters } from '@kbn/core-application-browser'; | ||
import { LOGS_ONBOARDING_FEEDBACK_LINK } from '@kbn/observability-shared-plugin/common'; | ||
import React from 'react'; | ||
import { useLocation } from 'react-router-dom'; | ||
|
||
export function ObservabilityOnboardingHeaderActionMenu() { | ||
export function ObservabilityOnboardingHeaderActionMenu({ | ||
setHeaderActionMenu, | ||
theme$, | ||
}: { | ||
setHeaderActionMenu: AppMountParameters['setHeaderActionMenu']; | ||
theme$: AppMountParameters['theme$']; | ||
}) { | ||
const location = useLocation(); | ||
const normalizedPathname = location.pathname.replace(/\/$/, ''); | ||
|
||
const isRootPage = normalizedPathname === ''; | ||
|
||
if (!isRootPage) { | ||
return ( | ||
<EuiButton | ||
data-test-subj="observabilityOnboardingPageGiveFeedback" | ||
href={LOGS_ONBOARDING_FEEDBACK_LINK} | ||
size="s" | ||
target="_blank" | ||
color="warning" | ||
iconType="editorComment" | ||
<HeaderMenuPortal | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes empty app header for oblt onboarding page #163326 |
||
setHeaderActionMenu={setHeaderActionMenu} | ||
theme$={theme$} | ||
> | ||
{i18n.translate('xpack.observability_onboarding.header.feedback', { | ||
defaultMessage: 'Give feedback', | ||
})} | ||
</EuiButton> | ||
<EuiButton | ||
data-test-subj="observabilityOnboardingPageGiveFeedback" | ||
href={LOGS_ONBOARDING_FEEDBACK_LINK} | ||
size="s" | ||
target="_blank" | ||
color="warning" | ||
iconType="editorComment" | ||
> | ||
{i18n.translate('xpack.observability_onboarding.header.feedback', { | ||
defaultMessage: 'Give feedback', | ||
})} | ||
</EuiButton> | ||
</HeaderMenuPortal> | ||
); | ||
} | ||
|
||
|
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.
Making the app menu height fixed.
It is also important to not render the menu if there are no actions. There is no good way for app menu component to know if there is content inside. We'd try to improve places where apps set the menu mount point, so that apps stopped setting the mount point if there is no actions
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.
This feels super elegant - it's also great that a plugin could theoretically update the
--kbnProjectHeaderAppActionMenuHeight
CSS variable and have everything update automatically, if they don't want to use the defaultxxxl
height. Feels really flexible / future-proof!