Skip to content

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

Merged
merged 18 commits into from
Jul 11, 2020

Conversation

kowsen
Copy link
Contributor

@kowsen kowsen commented Jun 12, 2020

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.

@kowsen kowsen requested a review from mmalerba as a code owner June 12, 2020 02:12
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 12, 2020
@kowsen kowsen changed the title Make MDC MatChipRow editable by connecting to the mdc web's new edit interface. feat(material-experimental/mdc-chips): Make chips editable by connecting to the mdc web editing interface Jun 16, 2020
@kowsen
Copy link
Contributor Author

kowsen commented Jun 17, 2020

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',
Copy link
Contributor

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?

Copy link
Member

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

@mmalerba
Copy link
Contributor

I've deployed this to my firebase instance to make it easier to test with different screenreaders: https://mmalerba-demo.firebaseapp.com/mdc-chips

@kowsen
Copy link
Contributor Author

kowsen commented Jun 19, 2020

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.

@jelbourn
Copy link
Member

jelbourn commented Jun 22, 2020

@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

@mmalerba
Copy link
Contributor

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

@kowsen
Copy link
Contributor Author

kowsen commented Jun 23, 2020

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.

@mmalerba
Copy link
Contributor

Yeah, I don't think we want a useless input on the other chips, so I would move it to MatChipRow

@kowsen
Copy link
Contributor Author

kowsen commented Jun 23, 2020

Moved it to MatChipRow.

Copy link
Contributor

@mmalerba mmalerba left a 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

@mmalerba mmalerba added lgtm action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Jun 25, 2020
Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

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

LGTM

@mmalerba mmalerba added G This is is related to a Google internal issue P2 The issue is important to a large percentage of users, with a workaround labels Jun 25, 2020
@kowsen
Copy link
Contributor Author

kowsen commented Jun 30, 2020

Is there anything more you need from me to get this merged in?

@mmalerba mmalerba added target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Jul 11, 2020
@mmalerba mmalerba merged commit 04024fe into angular:master Jul 11, 2020
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement G This is is related to a Google internal issue P2 The issue is important to a large percentage of users, with a workaround target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants