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

button click not disabled on within fieldset #1353

Open
asmadsen opened this issue Nov 10, 2022 · 5 comments
Open

button click not disabled on within fieldset #1353

asmadsen opened this issue Nov 10, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@asmadsen
Copy link

Describe the bug

click not disabled when wrapping button in fieldset

This is the same issue as #7711 in react

<fieldset disabled>
  <button onClick={() => alert('clicked')}>
    click me here and <span style={{color: 'red'}}>here</span>
  </button>
</fieldset>

Your Example Website or App

https://stackblitz.com/edit/solidjs-templates-jeskz7?file=src/App.tsx

Steps to Reproduce the Bug or Issue

Go to the stackblitz
Try to click the button both on the gray and red text
That'll show that clicking directly on the button doesn't trigger the onClick, while clicking on the child element will.

Expected behavior

Clicking on anything within the button should not trigger the onClick handler on the button if the fieldset is set to disabled.

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fe-disabled

@ryansolid
Copy link
Member

ryansolid commented Nov 10, 2022

I see. Looks like something a bit fiddly to fix. Interested to see if any framework with event delegation has solved this and how they went about doing so.

@asmadsen
Copy link
Author

I came across this working on making a port of headlessui. And there they have temporarily solved it by going up the DOM tree looking for a fieldset.

https://github.com/tailwindlabs/headlessui/blob/main/packages/@headlessui-react/src/utils/bugs.ts

@ryansolid ryansolid added the enhancement New feature or request label Dec 6, 2022
@LiQuidProQuo
Copy link
Contributor

LiQuidProQuo commented Dec 14, 2022

you can bind native events directly to the element, use on:click.
https://playground.solidjs.com/anonymous/ff4fa624-92c4-4b4c-a73a-3513cd455bb8

<button on:click={() => alert("clicked")}>
        click me here and <span style={{ color: "green" }}>good</span>
</button>

🚩 the headlessui fix posted, does not cover nested fieldsets case, see playground

@davidivkovic
Copy link

This issue seems to be fixed? I could not reproduce it anymore.

@ryansolid
Copy link
Member

Me neither.. But we didn't change anything to my knowledge. I don't see it in the latest Chrome or Firefox. But still seems to be in Safari.

Is it the browser behavior that changed?

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

No branches or pull requests

4 participants