Skip to content

Textfield's Icon cannot be Clicked on with on:click #582

Open
@mkmoisen

Description

@mkmoisen

Describe the bug
It does not seem possible to add anon:click to an Icon belonging to a Textfield.

Clicking on the Icon doesn't do anything.

To Reproduce
Steps to reproduce the behavior:

<script>
    import Textfield from '@smui/textfield';
    import Icon from '@smui/textfield/icon';

    let foo;
</script>

<form>

    <Textfield bind:value={foo} label="Foo">

        <Icon 
            class="material-icons" 
            slot="trailingIcon"
            on:click={
                () => {
                    console.log('bar');
                }
            }
        >
            add
        </Icon>

    </Textfield>

If you try to click on the icon, nothing will happen.

Expected behavior
The on:click event should activate when you click on the icon.

Desktop (please complete the following information):

  • Browser chrome, firefox

Additional context

It does work if you wrap the Icon in a div and add the on:click the the div. However, this causes a11y warnings that can only be resolved by writing more javascript code to handle keypresses.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentationworking as intendedThis behavior is expected

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions