Skip to content

Commit

Permalink
[ONL-6575] - Replace focus trap directive (#1319)
Browse files Browse the repository at this point in the history
* [ONL-6575] - dev - added focus trapcomposable

* [ONL-6575] - rm - custom directive from ec-modal

* [ONL-6575] - del ec-focus-trap directive

* [ONL-6575] - rm - ec-focus-trap mock

* [ONL-6575] - ref - rm export

* [ONL-6575] - dev - changed accepted module extension

* [ONL-6575] - dev - changed focusTrap activation logic

* [ONL-6575] - dev - adjusted mocking fn

* [ONL-6575] - added new tests cases

* [ONL-6575] - dev - updated tests

* [ONL-6575] - rm failing test

* [ONL-6575] - ref - updated new tests

* [ONL-6575] - dev - added second modal tests

* [ONL-6575] - ref - removed unecessary test case

* [ONL-6575] - ref - rm unecessary passed params

* [ONL-6575] - dev - reset inline options

* [ONL-6575] - added useFocusTrap global mock

* [ONL-6575] - ref - renamed file

* 2.1.11

* [ONL-6575] - fix - rm pause/unpause fns
  • Loading branch information
DisegnAle authored Oct 11, 2022
1 parent 3f29708 commit a61cd9f
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/components/ec-modal/ec-modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<script setup>
import { useFocusTrap } from '@vueuse/integrations/useFocusTrap';
import {
computed, onBeforeUnmount, onUnmounted, ref, useSlots, watchEffect,
computed, onBeforeUnmount, ref, useSlots, watch, watchEffect,
} from 'vue';
import * as KeyCode from '../../enums/key-code';
Expand Down Expand Up @@ -178,17 +178,13 @@ function getFocusTrapOptions() {
return options;
}
const { deactivate, pause, unpause } = useFocusTrap(focusTrapTarget, getFocusTrapOptions());
watchEffect(() => {
if (props.show) {
unpause();
} else {
pause();
const { deactivate } = useFocusTrap(focusTrapTarget, getFocusTrapOptions());
watch(() => focusTrapTarget.value, (targetEl) => {
if (!targetEl) {
deactivate();
}
});
onUnmounted(() => {
deactivate();
});
// close modal
function closeModal() {
Expand Down

1 comment on commit a61cd9f

@vercel
Copy link

@vercel vercel bot commented on a61cd9f Oct 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

chameleon – ./

chameleon-git-master-ebury.vercel.app
chameleon-ebury.vercel.app
chameleon-dead-plane.vercel.app

Please sign in to comment.