-
Notifications
You must be signed in to change notification settings - Fork 6.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(material/select): add page down/up button functionality #25508
feat(material/select): add page down/up button functionality #25508
Conversation
66cc5a4
to
55f3e82
Compare
@@ -280,6 +282,22 @@ export class ListKeyManager<T extends ListKeyManagerOption> { | |||
return; | |||
} | |||
|
|||
case PAGE_UP: | |||
if (isModifierAllowed) { | |||
this.setFirstItemActive(); |
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.
Page up/down aren't supposed to focus the first/last items, but rather move one page up/down in the list. The reason why we haven't implemented it in the ListKeyManager
is that it doesn't know how large the list is and the offset at which focus is set currently.
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.
Hi, if you take a look at my W3C link, it is possible to go 10 elements down/up or select the first/last option for the implentation of page_up/page_down. Or did I udnerstand somethin wrong from this reference implementation?
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.
The number 10 seems a little arbitrary to me, my understanding is that at least in native applications, it's supposed to go up/down by a page (hence the name).
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 definitly understand your concerns. I think the idea behing is, that a combobox is an "popup" which is after opening handled like it is a own page => therefore the jump of 10 (or last/first).
If you like I can implement the jump for 10 items, or we can forget the PR. I only saw it is an easy fix and thought i contribute it :)
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 that's fine, but we should make it configurable, similar to how it's done for the home/end keys. E.g. something with ListKeyManager.withPageUpDown(10)
.
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 pushed some tests and the integration with jumping 10 or to first/last one! Are there sth missing?
2af210e
to
3e1d4f2
Compare
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.
The CI is failing, because:
- The API goldens need to be updated. You can do it by running
yarn approve-api a11y
and committing the changed file. - There's a merge commit which is tripping up the commit message validator. Usually we rebase branches to avoid merge commits.
case PAGE_UP: | ||
if (this._pageUpAndDown.enabled && isModifierAllowed) { | ||
const targetIndex = this._activeItemIndex - this._pageUpAndDown.delta; | ||
this._setActiveItemByIndex(targetIndex > 0 ? targetIndex : 0, 1); |
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 should be able to simplify this and the PAGE_DOWN handling using the _setActiveItemByDelta
method instead.
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.
During writing the code I first had the same intention, but in my opinion this method can only be used to move 1 up or down and not an defined number or did i misunderstand anything?
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 see. Let's keep it like this for now.
791051e
to
24a2143
Compare
1effeda
to
24a2143
Compare
24a2143
to
a50fb0b
Compare
|
a50fb0b
to
c181fd8
Compare
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
case PAGE_UP: | ||
if (this._pageUpAndDown.enabled && isModifierAllowed) { | ||
const targetIndex = this._activeItemIndex - this._pageUpAndDown.delta; | ||
this._setActiveItemByIndex(targetIndex > 0 ? targetIndex : 0, 1); |
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 see. Let's keep it like this for now.
Nice, cu soon hopefully :) |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Hello,
small PR on adding some functionality according to (#3549) and implemented to fit the standard.
Best regards,
Martin