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

fix(iconbutton): handle activation click #5533

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vdegenne
Copy link
Contributor

fixes #5532

@vdegenne
Copy link
Contributor Author

@asyncLiz I followed the same idea as <md-text-button>, however to be totally honest I don't know if that's good or not. Requesting your review.

@asyncLiz
Copy link
Collaborator

The form label activation is used to make <label> work with some wrapped elements like <input>. I think it's fixing the issue as a side effect by forwarding clicks.

Can we try overriding the click method instead? I think it makes more sense to forward the initial click to the delegated element, rather than trigger a host click which re-triggers a button click.

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

If it's more complicated then I'm open to the current approach, but I want to add some documentation to explain what's going on.

@@ -126,6 +130,15 @@ export class IconButton extends iconButtonBaseClass implements FormSubmitter {

@state() private flipIcon = isRtl(this, this.flipIconInRtl);

@query('.link') private readonly linkElement!: HTMLElement | null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update this to capture both the button and anchor element that could be rendered. Both can have clicks forwarded to them.

@query('.icon-button') private readonly buttonElement!: HTMLElement | null;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

click() on an href icon-button has no effect.
2 participants