Skip to content

bug: lowercase for in htmlFor attribute doesn't work #3473

Closed
ionic-team/ionic-framework
#29666

Description

@katiedeangelis

Prerequisites

Stencil Version

2.17.1

Current Behavior

In my render function, I created a checkbox:

<label htmlFor={this.id}>My Label Text</label>
<input type="checkbox" id={this.id}></input>

When the component renders, "htmlFor" becomes "htmlfor" and the "My Label Text" does not toggle the checkbox.

Expected Behavior

In my render function, when "htmlFor" is added to a checkbox, that is the attribute (with case) that should render. When the component renders, I also expect that when the "My Label Text" label is clicked, the checkbox is toggled.

Steps to Reproduce

  1. Create a checkbox in a render function with the following label/input setup:
<label htmlFor={this.id}>My Label Text</label>
<input type="checkbox" id={this.id}></input>
  1. When the component renders, click the label
  2. Notice the checkbox does not toggle

Code Reproduction URL

Additional Information

I noticed in the stencil-public-runtime.ts file that there is an htmlfor element property on the LabelHTMLAttributes interface which is not correct:

   interface LabelHTMLAttributes<T> extends HTMLAttributes<T> {
        form?: string;
        htmlFor?: string;
        htmlfor?: string;
    }

Activity

  1. alicewriteswrongs commented on Jul 15, 2022

    @alicewriteswrongs
    Contributor

    Hi @katiedeangelis, thanks for filing this issue and for filing the related PR! I get the gist of what you're reporting here, but would you mind creating a simple reproduction repo that showcases this issue? Doing so will help us confirm what's going on and also evaluate your fix PR.

  2. added
    Awaiting Reply
    on Jul 15, 2022
  3. katiedeangelis commented on Jul 15, 2022

    @katiedeangelis
    ContributorAuthor
  4. removed
    Awaiting Reply
    on Jul 15, 2022
  5. added
    ionitron: needs reproduction
    on Jul 18, 2022
  6. ionitron-bot commented on Jul 18, 2022

    @ionitron-bot

    Thanks for the issue! This issue has been labeled as needs reproduction. This label is added to issues that need a code reproduction.

    Please reproduce this issue in an Stencil starter component library and provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.

    If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue.

    For a guide on how to create a good reproduction, see our Contributing Guide.

  7. added
    Resolution: Refine
    and removed
    ionitron: needs reproduction
    on Aug 3, 2022
  8. rwaskiewicz commented on Aug 3, 2022

    @rwaskiewicz
    Member

    Relabeling for the team to take a closer look. Thanks!

  9. tanner-reits commented on Jun 26, 2024

    @tanner-reits
    Contributor

    A fix for this was included in today's v4.19.0 release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Resolution: Refine

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions