-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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(pagination): add props to set size on the "item count" and "page number" select elements #4378
feat(pagination): add props to set size on the "item count" and "page number" select elements #4378
Conversation
Deploy preview for the-carbon-components ready! Built with commit 4ef0c7f https://deploy-preview-4378--the-carbon-components.netlify.com |
Deploy preview for carbon-elements ready! Built with commit 4ef0c7f |
Deploy preview for carbon-components-react ready! Built with commit 4ef0c7f https://deploy-preview-4378--carbon-components-react.netlify.com |
…bon into 4365_pagination-select-size
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.
it looks like the default size is 1 according to the spec but the actual implementation in browsers (including Chrome, Firefox, and Edge) defaults to 0
on a side note would this also be a potential issue for the "items per page" select as well?
Thanks for the feedback @joshblack & @emyarod! In my latest commits, I made a couple changes... namely:
What do you think about |
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.
I think the prop names are ok as long as they're documented
I want to get design feedback on the modified <select>
styles when we change the size
though. on Windows there is a flash of the default <select>
before the custom menu appears. I think we can avoid custom styles if possible since that's one of the differentiators between <select>
and our custom dropdown or overflow menu for example
Thanks @emyarod! I just pushed an update that sets the selector size Also could you elaborate on what you mean by this?
The |
right I am also in favor of keeping a |
@emyarod OH I see what you mean -- I tried to keep the styles to an absolute bare minimum. Have you gotten a chance to look at them when commented out? Here are some screenshots: Without a
|
@jendowns yeah looks like that's the default behavior when changing the |
Thanks @emyarod -- you keep mentioning "design", and I was wondering if there is someone in particular we should be tagging here so they see the PR? 😅 Just wanted to point out that the originating issue #4365 is a need from one of our application teams, in a product context. I'm happy to explore other options here but this seems like the least disruptive option available, using a native |
The original issue mentioned a text input and that seems like the better solution for navigating through a large list of pages.
That would let us avoid the long select menu and long scrolls if the number gets >100. Text input would also be easier for keyboard users who can enter the value rather than keying down to it and mobile users when their OS uses a picker for the select element. I'd prefer to see a number input solution to close #4365 For this issue of adding selector size knobs I think the visuals are fine if we also allow for aligning to the top or bottom. |
Thanks @designertyler -- Changing those select elements to text inputs (or even number inputs) would be a substantial code change. 😬 My assumption is that a change like that would be suited for a major release, and it would probably require some product validation? I would be very curious what our Security Design team thinks of a change like that as well. EDIT: I just want to be clear, I'm not fundamentally against the idea & of course it's not my decision to make! But it would definitely be out of scope for this PR & I'd want to step back to see some exploration of that before I tackled it myself. 😅 About handling "invalid" entries if using a
|
Yep, number input would need some more review and specs for all those different states. I'll go ahead and create a new issue for that and see if it's a feature we want in the future.
You're right! 👍
Yes, but now I think I take that back. The idea was that it would help when the pagination is at the bottom or top of the screen, but it takes it even further away from the normal select and may have some unintended consequences. What does everyone think? Another thing I missed is that the normal select dismisses after you select a number, but the custom-sized one doesn't. Can we have that behavior for the custom one? |
I'm okay with leaving it alone for now. 👍 Something to consider: in the event that someone is coming across that issue, they may need to reduce what they passed
Now for this, I'm not sure 😭 This is an interesting situation because adding a Maybe you'd have to listen for a selection with the keyboard or mouse and then somehow close the |
@jendowns we use size elsewhere to indicate the height/width/type setting on a component. It seems like ideally this wouldn't be hard coded, if the size is different than the number of pages then you get some really weird results. If a user activates the select, they should just be able to type the page their looking for right? This gets even more complex with dynamically loaded pages/content. Some issues in the current build, not sure if you're working on these: after changing the size, the input seems to open from from the middle nowOvershooting the size gets really wild |
When you say "we use size elsewhere" are you referring to just the word "size" in a prop or something else? 🤔 In this case, the "size" attribute on the
I'm not sure what you mean here? This would be an issue with the current implementation as well. It's a
Yes it's absolutely positioned, so that positioning is intentional. @designertyler suggested fixing it so it starts at the top or bottom of the But I'm still open to adding a prop for alignment -- it would be easy enough & involve setting
I understand what you are showing, but please consider that what you are demonstrating goes against the purpose of the props in this case? 😅 These props are being added to limit the number of lines shown to a small amount. If you are trying to show ALL options at once, then there's no point in modifying the prop.... or if you are trying to show MANY lines of options at once, well yes of course it will be as tall as you make it. There's nothing fundamentally "incorrect" about the screenshot with the "overshooting". If you have five options in a |
@jendowns couldn't we chose the smaller of the two numbers: the set size prop and the actual number of pages? Could this constraining just be solved with a max size? Rather than letting developers chose some arbitrary size they think looks right. |
@vpicone In my experience, arbitrarily setting restrictions frustrates consumers 😅 What if you set it to EDIT: What if the prop descriptions for Could also include a dev console warning if |
@vpicone Just noticed this question here:
If you are referring to setting this via a style, I don't recommend that. We are dealing with a If you are referring to setting a max via |
@jendowns I wasn't familiar with the What about |
Yeah no worries @vpicone -- it was new to me too before I started looking into the originating issue 👀 About the prop name, @joshblack & I had a convo about it earlier in this collapsed thread: #4378 (comment) Short version: consensus seems to be to keep the name more generic. So to me, using "selector" instead of "select" is more generic? (And doesn't reference the underlying |
@jendowns that makes sense, I really wish these were seperate components rather than needing to do everything through props! I’m not sure the size attribute makes sense on any other element than select so I’m not sure the risk of it changing is all that high (could be wrong here, didn’t hear the convo with @joshblack). I think we should have the most accurate prop names we can now rather than optimizing for a future where we don’t use a select element. Also Selector reminds me of css selectors 😂 |
@vpicone I'm totally okay with a prop name change, like:
I think @emyarod indicated he doesn't mind either way about the prop name? |
@joshblack @emyarod @vpicone @designertyler I just renamed the following props:
I was wondering if anyone has anymore feedback about this PR? @joshblack I noticed you marked this as "changes requested" but I think at this point I've addressed your original points? Just to get ahead of any questions resurfacing, in case someone missed the comments above -- here's my response to the feedback related to options overshooting the select if you pass in a big number (last part of the comment): #4378 (comment) Please let me know if you have any more questions or concerns! |
@jendowns I think we still need to come to a conclusion regarding @designertyler's point about dismissing the menu on select when the I think we will explore the number input feature regardless, but in order to continue with exposing the select |
@emyarod Agreed on the first point, this But to the second point about dismissing the |
@jendowns do you still want to move forward with this btw? I know we talked a bit on Slack but wanted to double-check what you were hoping the outcome could be here. If it's continuing with this PR, definitely understand! |
Oh @joshblack thanks for the reminder! Yeah I'll close this one out since the work we talked about would be taking place downstream in our repo first. 👍 |
Closes #4365
Proposal
Proposal to add a new prop
selectSize
itemCountSelectSize
&pageNumberSelectSize
that an app dev could use to set a "size" for thePagination
component inner page numberselect
element, in order to resolve the issue identified in #4365 when there are MANY pages.The
size
of the innerselect
gets updated to theselectSize
itemCountSelectSize
&pageNumberSelectSize
prop numbers (if it's provided) when theselect
is focussed -- and then it's set back to default /1
when theselect
is not focussed.Background
size
is aselect
attribute that can control the list box size of an openselect
: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/selectSo I'm thinking it could be useful in this case to use native
select
functionality with thesize
attribute to restrict the height of theselect
list box, in extreme cases like in #4365 where there are many pages. 🤔Questions
What do you think of theRenamed toselectSize
prop name? 😬 Is there a better name?itemCountSelectSize
&pageNumberSelectSize
0
not1
🤔 Any objections to setting it to1
by default though? (It seems to look fine Firefox either way)Do you want the prop on the otherAddedselect
element as well? The one for "items per page"?itemCountSelectSize
for the otherselect
element.Changelog
New
selectSize
itemCountSelectSize
&pageNumberSelectSize
props toPagination
selectSize
itemCountSelectSize
&pageNumberSelectSize
statesTesting / Reviewing
In the netlify deploy for
carbon-components-react
, open the knobs and changeselectSize
itemCountSelectSize
&pageNumberSelectSize
knobs to a number like 5 or 10. Then open theselect
to change the page. You should see something similar to this: