-
Notifications
You must be signed in to change notification settings - Fork 46
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
Flux button using wire:click
icon offset on hidden content
#824
Comments
@edwinvdpol I can reproduce the issue. I think you're right re: the loading spinner throwing the alignment off @calebporzio @joshhanley |
@edwinvdpol thanks for reporting! I had a quick dig to see if I could find a simple solution to this. But I think it's going to need @calebporzio's input. Here's a Volt component that shows both the bad and good scenarios and a small description of the issue and what I found. <?php
use Livewire\Volt\Component;
new class extends Component {
public $show = true;
public function test()
{
sleep(5);
}
};
?>
<div>
<p>This one demonstrates the problem:</p>
<flux:button icon="arrow-path" variant="primary" wire:click="test">
{{-- `sm:inline` normally added here to show icon and "Refresh" label on desktop and icon only on mobile --}}
{{-- Setting to just `hidden` allows us to see the problem on desktop --}}
<span class="hidden">Refresh</span>
</flux:button>
<p>This shows it working fine when we remove `wire:click`:</p>
<flux:button icon="arrow-path" variant="primary">
{{-- `sm:inline` normally added here to show icon and "Refresh" label on desktop and icon only on mobile --}}
{{-- Setting to just `hidden` allows us to see the problem on desktop --}}
<span class="hidden">Refresh</span>
</flux:button>
<p>
The problem is due to the `wire:click` on the first button, the button component wraps the slot in a<br />
`<span></span>` to ensure there is a target element to change the opacity of the button contents<br />
when `wire:loading` is running and the loading element is shown. But this is a `gap-2` applied to<br />
the button which is being shown even when there are no slot contents, due to the wrapping span.
</p>
</div> |
Alright I've submitted a PR #988 with a possible fix to this. But the problem is it's not a clean fix and instead comes with it's own trade offs. See the PR for more details. |
Flux version
v1.0.29
Livewire version
v3.5.16
What is the problem?
Hit there 👋
Given the code below, the icon in the button is not centered when using hidden content.
When removing the
wire:click
attribute from the button, it is centered.I think the loading spinner, or the extra span is what causes this behaviour.
Code snippets
How do you expect it to work?
It should be centered like this:
A nice to have, is that it also should behave like the
square
variant, but I can image that would be complicated. 😉Please confirm (incomplete submissions will not be addressed)
The text was updated successfully, but these errors were encountered: