-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Select Menu component #808
Conversation
This pull request is automatically deployed with Now. |
So that any icon can be used.
The CSS doesn't seem to support native checkbox inputs out of the box. Could we support something like: <label class="SelectMenu-item">
<input type="checkbox">
<%= octicon "check", class: "SelectMenu-icon" %>
Check this out
</label> and then style it with: .SelectMenu-item {
input[type=checkbox] { display: none; }
.SelectMenu-icon ~ input[type=checkbox] { visibility: hidden; }
.SelectMenu-icon ~ input[type=checkbox]:checked { visibility: visible; }
} Or is that too clever? 🤔 |
Yeah, that would be clever. 🤓 On .com we sometimes do use the details-menu element with <div class="SelectMenu-list">
<label class="SelectMenu-item" role="menuitemradio" aria-checked="<%= type_filter.to_s == value %>" tabindex="0">
<%= radio_button_tag "type", value, type_filter.to_s == value, class: "d-none", "data-autosubmit": "true" %>
<%= octicon("check", class: "SelectMenu-icon") %>
<span class="text-normal" data-menu-button-text><%= name %></span>
</label>
</div> Is that ok too? It would leave us the option to also style the |
FWIW in However, I think it isn't necessary to support the But I do think it'd be good to support a CSS class checked state alternative. It'd be useful when .SelectMenu-item[aria-checked="true"],
.SelectMenu-item.SelectMenu-item--checked {
...
} |
That makes sense to me, but I wonder if we can do it with other ARIA attributes, e.g. In other words: Would we only use |
@shawnbot That makes sense to me. We can revisit if/when a pressing use case comes up. |
Sounds good. An additional |
Yeah I think that is also a case to revisit if/when we need them. |
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.
Okay, let's ship this! I have some thoughts on layout spacing, but I think those would be best addressed in follow-ups. Thanks for all your hard work on this, @simurai !
This is an alternative to #801. It introduces a responsive
.SelectMenu
component to Primer.Markup
Below a simple example, more options in the documentation.
Modifiers
By default, when the viewport is smaller than
sm
, the Select Menu has an auto-height and is vertically centered. If the Select Menu has a filter, the.SelectMenu--hasFilter
modifier can be added to make the Select Menu stick to the top and have a fixed height. This allows the list to be filtered without the input jumping around.xs
sm
.SelectMenu--hasFilter
Must have
aria/role
attributesNice to have
border-radius/overflow: auto
issue in Safari iOS. -> It works by addingoverflow: hidden
on a parent (.SelectMenu-modal
) element.:last-child
pseudo selector can't really be used because sometimes the last element gets hidden but remains in the DOM. And the.last-visible
class is deprecated. Or an<div class="sr-only" data-filterable-notice="" aria-live="polite">10 results found.</div>
element gets added as last element. -> ☝️ Above fix also fixed this. Now all child elements should get "masked" with rounded corners. Downside: Overflowing content is no possible anymore. Let's see if we need it.id
is needed to make thedata-toggle-for
work for the close button. Should be fine in some cases, but could also become more complex when a Select Menu gets used multiple times on the same page and a unique ID needs to be passed from a parent of the partial. Would be great if<details-menu>
would have an equivalent todata-close-dialog
that doesn't require a unique ID..SelectMenu
AND the current.select-menu
will be aroundfor a whileforever 🙃, both select menus should look and behave similar. They are currently pretty close, but when taking a closer look, there are still some details that are different..com tests
Issues/PR->wontfix
(for now). These are a lot more complex and probably need custom CSS, changes to JS and ERB partials.Ref. https://github.com/github/design-systems/issues/601#issuecomment-489551559