Skip to content

Commit

Permalink
Fix close-explicitly in Vue + update tests (see #36) (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalbaljet authored Oct 29, 2024
1 parent c669751 commit d0f3eb6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
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

0 comments on commit d0f3eb6

Please sign in to comment.