Skip to content

[6.x] Modals#11879

Merged
jasonvarga merged 5 commits into
uifrom
modals
Jun 17, 2025
Merged

[6.x] Modals#11879
jasonvarga merged 5 commits into
uifrom
modals

Conversation

@duncanmcclean

@duncanmcclean duncanmcclean commented Jun 17, 2025

Copy link
Copy Markdown
Member

This pull request updates modals across our application to use the new <Modal> UI component.

In the process, I've also converted buttons/inputs/selects/etc in modals to use UI new versions of those components.

Modal Open/Closed State

This PR also makes some changes to how a modal's open state is controlled.

Previously, modals would open after the user clicked the "trigger". This meant that there wasn't any way to open a modal programatically, or prevent it from closing (in the case of an in-progress AJAX request).

While the modal's open state can still be handled by the model itself, it can now also be opened & closed using v-model bindings:

<!-- When a trigger exists, the modal will handle its own state -->
<Modal>
    <template #trigger>
        <Button text="Open the modal" />
    </template>

    <p>...</p>
</Modal>

<!-- When the :open prop is provided, the parent component will handle the state -->
<script setup>
const modalOpen = ref(true);

function updateOpenState(value) {
    if (ajaxRequestInProgress) {
        return;
    }

    modalOpen.value = value;
}
</script>

<Modal :open="modalOpen" @update:open="updateOpenState">
    <p>...</p>
</Modal>

Otherwise, as soon as the `<Modal>` component is rendered, its displayed.

The modal can still be used *without* the parent component managing state.
@duncanmcclean duncanmcclean marked this pull request as ready for review June 17, 2025 11:04
@duncanmcclean duncanmcclean requested a review from jasonvarga June 17, 2025 11:04
@duncanmcclean

Copy link
Copy Markdown
Member Author

@jasonvarga What are your thoughts on the open/close changes in this PR?

@jasonvarga jasonvarga merged commit 07fa0b6 into ui Jun 17, 2025
17 of 18 checks passed
@jasonvarga jasonvarga deleted the modals branch June 17, 2025 17:48
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.

2 participants