-
Notifications
You must be signed in to change notification settings - Fork 241
chore: make submenu positioning theme-aware #5966
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
base: main
Are you sure you want to change the base?
Conversation
|
📚 Branch Preview Links🔍 First Generation Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
| * - Spectrum/Express: -5px | ||
| * - Spectrum Two: -9px | ||
| */ | ||
| --swc-submenu-offset-block: var(--system-submenu-offset-block, -5px); |
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.
You are overriding this in MenuItem.ts. Can you remove the inline style and place the rule here?
In menu-item.css
sp-popover {
margin-block-start: var(--swc-submenu-offset-block, -5px);
}And keep the existing host var:
:host {
--swc-submenu-offset-block: var(--system-submenu-offset-block, -5px);
}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.
Done!
| @slottable-request=${this.handleSlottableRequest} | ||
| > | ||
| <sp-popover | ||
| style="margin-block-start: var(--system-submenu-offset-block, -5px)" |
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.
Are we letting downstream customers to override this. Is this the plan?
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.
Moved this from inline style to the menu-item styles!
Rajdeepc
left a comment
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.
LGTM! If you update the hash we are good to go here. Thanks for resolving the review comments. Looks clean now.
Description
This PR moves the submenu vertical offset from JavaScript to CSS custom properties to support theme-specific positioning values. The submenu popover positioning now respects each theme's design requirements:
The changes involve:
overlay.offsetarray and applying it viamargin-block-starton the popover element--swc-submenu-offset-blockcustom property inmenu-item.cssthat references theme-specific values--system-submenu-offset-blockper theme insystem-theme-bridge.cssfiles[-10, -5]to[-10, 0]since vertical offset is now handled by CSSMotivation and context
In the
spectrum-twotheme, submenus need different vertical offset across fromspectrumandexpressthemes to align properly with their parent menu items. Previously, the offset was hardcoded in JavaScript, making it not viable to adapt to theme-specific requirements. By moving this value to CSS custom properties, we enable each theme to define its own positioning.This improves visual alignment across all supported themes.
Screenshots (if appropriate)
Before:

After:

Author's checklist
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
Compare
mainvs this PRDevice review