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

feat: contextual menu css position #4915

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion scss/_patterns_contextual-menu.scss
Expand Up @@ -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?

max-width: 21rem;
min-width: 10rem;
padding: 0;
Expand Down Expand Up @@ -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.

// All buttons have a margin right, unless they are a last child.
// In cases where contextual menu toggle is a button, we do not want it to
// have a margin, but since it is never the last child in this pattern,
Expand Down
4 changes: 0 additions & 4 deletions templates/docs/examples/patterns/contextual-menu/_script.js
Expand Up @@ -12,10 +12,6 @@ function toggleMenu(element, show, top) {
element.setAttribute('aria-expanded', show);
target.setAttribute('aria-hidden', !show);

if (typeof top !== 'undefined') {
target.style.top = top + 'px';
}

if (show) {
target.focus();
}
Expand Down