-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(material-experimental/mdc-chips): Make chips editable by connecting to the mdc web editing interface #19618
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
Conversation
Make MatChipEditInput a Directive instead of a Component
I did some thinking over the weekend and changed this over to use a directive for the input instead of a component to better match the way other things like matChipRemove work. Sorry for the thrashing if you've already started taking a look at this - let me know if you'd like me to revert it to the old approach! |
selector: 'span[matChipEditInput]', | ||
host: { | ||
'class': 'mdc-chip__primary-action mat-chip-edit-input', | ||
'role': 'textbox', |
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.
@jelbourn are you aware of any a11y issues with this?
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 don't really know the a11y nuances of contenteditable
, so this would require some manual testing
I've deployed this to my firebase instance to make it easier to test with different screenreaders: https://mmalerba-demo.firebaseapp.com/mdc-chips |
I deployed a version that uses an input instead of a contenteditable span to test a11y against, in case it's helpful to compare: https://kowsen-demo-ba72c.firebaseapp.com/mdc-chips It seems to have identical behavior in Voiceover. The only potentially strange thing is that it doesn't announce when the chip has been edited (in either version), but I think it makes sense to leave that to the host component since they're the one that decides how to handle the "edited" event and if it should change the model. |
@mmalerba I tried both in NVDA and they work the same. Neither gives the best indication that activating the "button" will edit the entry, but I'm not sure there's anything we can do for that at the library level |
Yeah, I saw the same thing with ChromeVox on Chrome OS, so it seems like this approach should be fine. @kowsen I do have a question though, is it possible for a selectable chip to be editable? In this case it seems like the "enter" key would be the trigger for both toggling selection and toggling edit mode |
No, that shouldn't be possible now - MatChipOption doesn't set the "mdc-chip--editable" class on the host, so the editable input will have no effect. If that isn't acceptable I could move the editable input and edited output into MatChipRow so it won't bleed into other MatChip subclasses. |
Yeah, I don't think we want a useless input on the other chips, so I would move it to |
Moved it to MatChipRow. |
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.
Looks good overall, just a couple small nits
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
Is there anything more you need from me to get this merged in? |
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. |
This connects MatChipRow to the new editable interface introduced in this PR so users can edit chips in a chip grid.
With these changes, when the "editable" input on a mat-chip-row is set to true, double clicking it or pressing enter when the chip's primary action is focused will switch it to an "editing" mode. When the user hits enter or removes focus from that chip, it will revert to its earlier state and emit the value that was modified by the user so the host components can handle updating the model.
I've also updated the demo page so developers can enable this flag there, and verified that the full test suite still passes.