components icon indicating copy to clipboard operation
components copied to clipboard

feat(slide-toggle): prevent value change

Open slavafomin opened this issue 2 months ago • 1 comments

Feature Description

Hello! I'm using the slide-toggle component and I want to control when and how it's value changes. Just like controlled components in React. However, I can't find a way to do so.

When I pass a signal (not a model) to the component via [checked]="isChecked()" the value of the component continues to change once a user clicks on it (totally ignoring the fact that the symbol is not changed). This looks like a bug to me, or at least something very counter-intuitive.

Then I've tried to hook into the (change) event to manually call preventDefault() on it when the value changes, but the event object provided to the event handler doesn't have such method.

Calling preventDefault() from toggle/click event handlers doesn't have any effect as well.

What can I do to take the component under control?

Thanks.

Use Case

No response

slavafomin avatar Apr 13 '24 06:04 slavafomin

There's some precedent for this with the clickAction option in MatCheckbox already so we should be able to something similar here.

crisbeto avatar Apr 15 '24 08:04 crisbeto