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(mdc-list): introduce selection change event #7443

Conversation

devversion
Copy link
Contributor

Introduces a new custom event called MDCList:selectionChange that
fires whenever the selection of the list has changed through user
interaction. This matches with the semantics of the native change
event of input controls.

This event is useful as not every type of list has an underlying
native control, like in the checkbox-type list, where the change
event from the control may bubble up. Even for those cases though
the native event is not guaranteed to fire in all cases. e.g. it
does not fire when a user leverages the CTRL + A keybinding we
support in the list foundation.

This commit adds a new type of event/notification that can be
leveraged in the foundation through an adapter method (needed by
Angular), or consumers could use it through MDCList:selectionChange.

Note that the custom action event being emitted here is not semantically
equivalent as this one fires regardless of whether the selection has actually changed
or not. This seems like another use-cases, as seen in the MDC menu.

Note: also fixes that the unit tests did not run properly as there was a fit leftover pushed to master. This commit fixes that and sets up a lint to prevent this in the future.

Introduces a new custom event called `MDCList:selectionChange` that
fires whenever the selection of the list has changed through user
interaction. This matches with the semantics of the native `change`
event of input controls.

This event is useful as not every type of list has an underlying
native control, like in the checkbox-type list, where the `change`
event from the control may bubble up. Even for those cases though
the native event is not guaranteed to fire in all cases. e.g. it
does not fire when a user leverages the `CTRL + A` keybinding we
support in the list foundation.

This commit adds a new type of event/notification that can be
leveraged in the foundation through an adapter method (needed by
Angular), or consumers could use it through `MDCList:selectionChange`.
Copy link

@brandondiamond brandondiamond left a comment

Choose a reason for hiding this comment

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

Lots of nice improvements to names and code organization. Thanks for all the effort that went into this PR!

Added a general comment about circumstances in which the underlying control would have received a click event -- I may be misunderstanding the comment, but the intention is for these controls not to be tappable/clickable (via pointer-events: none).

packages/mdc-list/foundation.ts Outdated Show resolved Hide resolved
packages/mdc-list/foundation.ts Show resolved Hide resolved
devversion added a commit to devversion/material2 that referenced this pull request Dec 9, 2021
…Click signature change

Accounts for the mdc-list handleClick signature/semantics change as
with:
material-components/material-components-web#7443.
devversion added a commit to devversion/material2 that referenced this pull request Dec 9, 2021
…Click signature change

Accounts for the mdc-list handleClick signature/semantics change as
with:
material-components/material-components-web#7443.
devversion added a commit to devversion/material2 that referenced this pull request Dec 9, 2021
…Click signature change

Accounts for the mdc-list handleClick signature/semantics change as
with:
material-components/material-components-web#7443.
devversion added a commit to devversion/material2 that referenced this pull request Dec 9, 2021
…Click signature change

Accounts for the mdc-list handleClick signature/semantics change as
with:
material-components/material-components-web#7443.
devversion added a commit to devversion/material2 that referenced this pull request Dec 10, 2021
…Click signature change

Accounts for the mdc-list handleClick signature/semantics change as
with:
material-components/material-components-web#7443.
andrewseguin pushed a commit to angular/components that referenced this pull request Dec 10, 2021
…Click signature change (#24076)

Accounts for the mdc-list handleClick signature/semantics change as
with:
material-components/material-components-web#7443.

(cherry picked from commit 97ec228)
andrewseguin pushed a commit to angular/components that referenced this pull request Dec 10, 2021
…Click signature change (#24076)

Accounts for the mdc-list handleClick signature/semantics change as
with:
material-components/material-components-web#7443.
@devversion
Copy link
Contributor Author

merged with 7d8ea46

@devversion devversion closed this Dec 10, 2021
forsti0506 pushed a commit to forsti0506/components that referenced this pull request Apr 3, 2022
…Click signature change (angular#24076)

Accounts for the mdc-list handleClick signature/semantics change as
with:
material-components/material-components-web#7443.
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.

2 participants