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

Fix close-explicitly in Vue + update tests (see #36) #40

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions demo-app/tests/Browser/ConfigPropsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ public function it_can_set_config_globally(bool $navigate)
->waitForText('Prop from Config')
->clickLink('Open')
->waitFor('.im-dialog')
->keys('', ['{escape}'])
// ->assertAttribute('#app', 'inert', '') // Close explicitly TODO: FIX
->keys('', ['{escape}']) // Escape key does not close the dialog
->assertAttribute('#app', 'aria-hidden', 'true')
->clickLink('Open') // Clicking outside the dialog does not close it
->assertAttribute('#app', 'aria-hidden', 'true')
->assertPresent('.im-slideover-content') // Slideover
->assertMissing('.im-close-button') // No close button
->assertAttributeContains('.im-slideover-positioner', 'class', 'justify-start') // Left-aligned
Expand Down
6 changes: 4 additions & 2 deletions demo-app/tests/Browser/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ public function it_passes_the_props_from_the_modal(bool $navigate)
->waitForText('Prop from Modal')
->clickLink('Open Slideover')
->waitFor('.im-dialog')
->keys('', ['{escape}'])
// ->assertAttribute('#app', 'inert', '') // Close explicitly TODO: FIX
->keys('', ['{escape}']) // Escape key does not close the dialog
->assertAttribute('#app', 'aria-hidden', 'true')
->clickLink('Open Slideover') // Clicking outside the dialog does not close it
->assertAttribute('#app', 'aria-hidden', 'true')
->assertPresent('.im-slideover-content') // Slideover
->assertMissing('.im-close-button') // No close button
->assertAttributeContains('.im-slideover-positioner', 'class', 'justify-start') // Left-aligned
Expand Down
6 changes: 4 additions & 2 deletions demo-app/tests/Browser/ModalLinkPropsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ public function it_passes_the_props_from_the_modal_link(bool $navigate)
->waitForText('Prop from ModalLink')
->clickLink('Edit User 1')
->waitFor('.im-dialog')
->keys('', ['{escape}'])
// ->assertAttribute('#app', 'inert', '') // Close explicitly TODO: FIX
->keys('', ['{escape}']) // Escape key does not close the dialog
->assertAttribute('#app', 'aria-hidden', 'true')
->clickLink('Edit User 1') // Clicking outside the dialog does not close it
->assertAttribute('#app', 'aria-hidden', 'true')
->assertPresent('.im-slideover-content') // Slideover
->assertMissing('.im-close-button') // No close button
->assertAttributeContains('.im-slideover-positioner', 'class', 'justify-start') // Left-aligned
Expand Down
3 changes: 2 additions & 1 deletion vue/src/ModalContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ defineProps({
>
<DialogContent
:aria-describedby="undefined"
:trap-focus="config?.closeExplicitly"
:class="{
'im-modal-wrapper w-full transition duration-300 ease-in-out': true,
'blur-sm': !modalContext.onTopOfStack,
Expand All @@ -45,6 +44,8 @@ defineProps({
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl': config.maxWidth == '6xl',
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl': config.maxWidth == '7xl',
}"
@escape-key-down="($event) => config?.closeExplicitly && $event.preventDefault()"
@interact-outside="($event) => config?.closeExplicitly && $event.preventDefault()"
>
<VisuallyHidden as-child>
<DialogTitle />
Expand Down
3 changes: 2 additions & 1 deletion vue/src/SlideoverContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ defineProps({
>
<DialogContent
:aria-describedby="undefined"
:trap-focus="config?.closeExplicitly"
:class="{
'im-slideover-wrapper w-full transition duration-300 ease-in-out': true,
'blur-sm': !modalContext.onTopOfStack,
Expand All @@ -44,6 +43,8 @@ defineProps({
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl': config.maxWidth == '6xl',
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl': config.maxWidth == '7xl',
}"
@escape-key-down="($event) => config?.closeExplicitly && $event.preventDefault()"
@interact-outside="($event) => config?.closeExplicitly && $event.preventDefault()"
>
<VisuallyHidden as-child>
<DialogTitle />
Expand Down