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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: contextual menu css position #4915

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

petermakowski
Copy link
Contributor

@petermakowski petermakowski commented Nov 22, 2023

Done

This PR removes the need for using JavaScript for vertical positioning of the contextual menu and will subsequently allow to simplify implementations of this pattern.

  • feat: contextual menu css position

QA

  • Open demo
  • Go to /docs/patterns/contextual-menu and ensure all examples are displayed exactly the same as before

Check if PR is ready for release

If this PR contains Vanilla SCSS code changes, it should contain the following changes to make sure it's ready for the release:

  • PR should have one of the following labels to automatically categorise it in release notes:
    • Feature 馃巵, Breaking Change 馃挘, Bug 馃悰, Documentation 馃摑, Maintenance 馃敤.
  • Vanilla version in package.json should be updated relative to the most recent release, following semver convention:
    • if CSS class names are not changed it can be bugfix relesase (x.x.X)
    • if CSS class names are changed/added/removed it should be minor version (x.X.0)
    • see the wiki for more details
  • Any changes to component class names (new patterns, variants, removed or added features) should be listed on the what's new page.

Screenshots

No visual changes, looks exactly the same way as before. E.g.:
Google Chrome screenshot 001104@2x

Notes

Somewhat related PR in react-components: canonical/react-components#1000

@@ -16,7 +16,7 @@
@extend %vf-has-box-shadow;

display: none;
margin: 0;
margin: 0 0 $input-margin-bottom 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

How is margin on the dropdown related to placement?

Contextual menu is absolutely positioned, so I'm not sure if bottom margin on it affects anything?

@@ -83,6 +83,8 @@
}

.p-contextual-menu__toggle {
// Remove margin bottom for the dropdown menu to be aligned with the toggle
margin-bottom: 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if we can do that. In our example p-contextual-menu__toggle is used on the button, and in such case it would override the default margin on the button.

The fact that button has contextual menu should not affect its margin.

I guess this was the main reason to use JS for positioning - so we can calculate top position regardless of margin that element having contextual menu may have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants