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

[maybe bug] Modal without trigger still creates trigger top left in the layout #3206

Closed
ktarmyshov opened this issue Feb 10, 2025 · 6 comments
Labels
bug Something isn't working
Milestone

Comments

@ktarmyshov
Copy link

Current Behavior

I am migrating to V3 and some of my actions, which call modal/dialog, are in popover. I initially put Modal with trigger and content. But when I select an action and close the popover, I get a warning "something with window/frame is null" and my modal/dialog does not appear. So I implemented my own modal stack/overlay in a similar way as it was with the V2, and my modals don't have "trigger" defined.
+layout.svelte (root)

<!-- Overlays -->
<ModalStack />

I also need this to show an error if it happens on form action.
When such 'trigger'-less modals appear, there also appears the trigger element in the html, which is empty but it does has size and shifts the whole content (under the dim).

If I show more modals (e.g. form, and then the error, more such elements appear).

<span data-testid="modal" class=" "><button data-scope="dialog" data-part="trigger" id="dialog:hy0vnfbgdu50:trigger" aria-haspopup="dialog" type="button" aria-expanded="true" data-state="open" aria-controls="dialog:hy0vnfbgdu50:content" class="modal-trigger  "><!----></button>  <!----></span>

<span data-testid="modal" class=" "><button data-scope="dialog" data-part="trigger" id="dialog:d8kcn0zvgri3:trigger" aria-haspopup="dialog" type="button" aria-expanded="true" data-state="open" aria-controls="dialog:d8kcn0zvgri3:content" class="modal-trigger  "><!----></button>  <!----></span>

Image

Image

So my request is if 'trigger' is not provided, then this html elements should not appear.

Thank you

Expected Behavior

Trigger html elements should not appear for the 'trigger'-less modals

Steps To Reproduce

<Modal open={true}>
  {#snippet content()}
    whatever
  {/snippet}
</Modal>

Link to Reproduction / Stackblitz

No response

More Information

No response

@ktarmyshov ktarmyshov added the bug Something isn't working label Feb 10, 2025
@ktarmyshov
Copy link
Author

Adding class "hidden" to trigger base as workaround solves the issue.

@endigo9740 endigo9740 added this to the v3.0 (Next) milestone Feb 12, 2025
@phamduylong
Copy link
Contributor

This is reasonable. Right now if trigger isn't provided, it will show an empty button. Could be rewritten as:

{#if trigger}
    <button {...triggerProps} class="{triggerBase} {triggerBackground} {triggerClasses}" {disabled} type="button">
    	{@render trigger?.()}
    </button>
{/if}

I'll do this for Popover, Tooltip and Modal. Combobox isn't a viable use case.

@phamduylong
Copy link
Contributor

Could be worth adding notes for triggerBackground, triggerBase and triggerClasses that they are not useful unless trigger is provided.

@endigo9740
Copy link
Contributor

Could be worth adding notes for triggerBackground, triggerBase and triggerClasses that they are not useful unless trigger is provided.

I think this should be obvious. If you don't use the feature, the styles won't affect anything.

@phamduylong
Copy link
Contributor

@endigo9740 this can be closed.

@endigo9740
Copy link
Contributor

Man I'm so ready to have auto-close back once we launch v3 :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants