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

x-collapse not working properly when used with click.away #2201

Merged
merged 3 commits into from Oct 11, 2021

Conversation

SimoTod
Copy link
Collaborator

@SimoTod SimoTod commented Oct 9, 2021

Note, this change is could be considered as a mild BC.
Before this PR an element was considered as 'not visible' if both the outer width and outer height were 0. This was working okay with a standard x-show but with x-collapse, only the height is 0.
With this PR, an element is considered as "not visible" even if only one of the 2 is 0. From a human point of view, this makes sense because an element with height = 0 is not really visible. Despite being a behavioural change, I don't think anyone was expecting click away to trigger in this scenario so it won't probably break anything to anyone.

Update
The approach above was still not working if the element had borders as the outer height wasn't 0 (borders and paddings are still visible when the element is collapsed, not sure if it's intentional). The new approach just add a special check for el._x_isShown === false

@SimoTod SimoTod force-pushed the bug/x-collapse-and-click-away branch from 2272be1 to a53c39d Compare October 9, 2021 14:39
@calebporzio
Copy link
Collaborator

This is perfect(as always) thanks Simone!

@calebporzio calebporzio merged commit be9a12c into alpinejs:main Oct 11, 2021
@SimoTod SimoTod deleted the bug/x-collapse-and-click-away branch November 20, 2021 00:28
@SimoTod SimoTod restored the bug/x-collapse-and-click-away branch November 20, 2021 00:29
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

Successfully merging this pull request may close these issues.

None yet

2 participants