-
-
Notifications
You must be signed in to change notification settings - Fork 206
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
Data State Inconsistency #1041
Labels
bug
Something isn't working
Comments
anatolzak
added a commit
to anatolzak/melt-ui
that referenced
this issue
Mar 3, 2024
I agree it should be based on open state. But display should be based on forceVisible too, meaning it should be based on isVisible |
@TGlide 100%! I accidentally wrote that display should be based on |
This was referenced Mar 27, 2024
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
There is currently an inconsistency in how we calculate the
data-state
attribute.With Dialog Content and Overlay, Tooltip Content:
With the rest of the components (Link Preview Content, Menu Content, Popover Content, etc.):
I believe that the
data-state
should be based on$open
, because if we useforceVisible: true
and always keep the content mounted,data-state
will always beopen
.The only place where this decision between
$open
and$isVisible
matters, is when the user usesforceVisible: true
, in which case if they unmount the component when$open
isfalse
and use a svelte transition,data-state
will actually stayopen
because of how svelte internally freezes the component to transition it out. But if the user always leaves it as mounted and just changes the content's visibility,data-state
should beclosed
, which is not currently the case with the codebase.Now, if we agree that we should change the
data-state
based on$open
, we need to make sure that we don't override styles set by floating-ui in certain components.The above code would "rerender" every time the
$open
state changes, and if the user never unmounts the content, the styles will get reset to an empty string, thereby removing the styles set by floating-ui, which causes the component to jump. This was already fixed in the case of the tooltip content here #1010The solution was to use the below code
... and to remove properties with undefined values returned from the tooltip content, because if we set style to undefined, svelte will also reset the styles set by floating-ui. So we needed to remove the style property altogether.
So since this will be a problem in all builders, we should remove properties with undefined values in the
makeElement
function.Reproduction
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: