material-components / material-web

Material Design Web Components
https://material-web.dev
Apache License 2.0
9.36k stars 897 forks source link

list: programmatic click not working #5705

Open vdegenne opened 2 months ago

vdegenne commented 2 months ago

What is affected?

Component

Description

click method doesn't work on a link md-list-item.

Reproduction

https://lit.dev/playground/#gist=dc8128d652233e2c84c8e5a93d985ada

Workaround

One workaround is to use listItemRoot to access the anchor element:

listItem.listItemRoot.click();

However, listItemRoot is marked as protected.

Is this a regression?

Yes. This used to work, but now it doesn't.

Affected versions

2.1.0

Browser/OS/Node environment

Chrome/Firefox

asyncLiz commented 2 months ago

We should be able to fix this by adding a click override to forward the click, similar to the list item's focus override.

override click() {
  this.listItemRoot?.click();
}