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 id prop not passed to tag when disabled #1336

Open
ncvc opened this issue Apr 30, 2024 · 4 comments
Open

Button id prop not passed to tag when disabled #1336

ncvc opened this issue Apr 30, 2024 · 4 comments

Comments

@ncvc
Copy link

ncvc commented Apr 30, 2024

Describe the bug

The fix to this issue (commit here) introduced a bug - the id prop is no longer passed to the button tag when the Button is disabled because $$restProps is no longer being passed to svelte:element when the Button is disabled. For us, this means that we can't target a button by id with a tooltip when that button is disabled.

Reproduction

<script>
  import { Button } from 'flowbite-svelte';
</script>

<Button id="enabledButton">ID present</Button>
<Button disabled id="disabledButton">ID not present</Button>

Flowbite version and System Info

System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 65.88 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
  Browsers:
    Chrome: 124.0.6367.91
    Safari: 17.4.1
  npmPackages:
    @sveltejs/kit: ^2.5.7 => 2.5.7
    flowbite-svelte: ^0.46.1 => 0.46.1
    svelte: ^4.2.15 => 4.2.15
    vite: ^5.2.10 => 5.2.10
@shinokada
Copy link
Collaborator

Is adding id prop the solution?

@ncvc
Copy link
Author

ncvc commented May 1, 2024

That would fix my specific issue, but I think users will expect all the props to be passed into the svelte:element tag when the button is disabled, since that's the behavior when it's not disabled.

Why did restProps need to be removed here? 11d5308#diff-bb40d1bd5fefb1ab555586115b3092620c9b98dc5ddf6f33115899c19f4c442eR130

@shinokada
Copy link
Collaborator

By adding ...$$restProps, you are allowing on:click event that trigger the event even if you have disabled attribute.

@ncvc
Copy link
Author

ncvc commented May 2, 2024

Gotcha - what if we do something like this? #1339

Just opened the PR to show the change, I haven't tested it since I don't have the local dev environment for this setup. Feel free to take over / edit that PR or close it and open your own

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

No branches or pull requests

2 participants