Skip to content

Commit

Permalink
[CHOPS-888] disabled scrolling when mobile menu is open (#2004)
Browse files Browse the repository at this point in the history
* disabled scrolling when mobile menu is open

* bumped to 2.8.15
  • Loading branch information
corinaper authored Jul 8, 2024
1 parent d3739fb commit 7b9d34c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ebury/chameleon-components",
"version": "2.8.14",
"version": "2.8.15",
"main": "src/main.ts",
"sideEffects": false,
"author": "Ebury Team (http://labs.ebury.rocks/)",
Expand Down
4 changes: 4 additions & 0 deletions src/components/ec-navigation/ec-navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,17 @@ describe('EcNavigation', () => {
},
});

expect(document.body.style.overflow).not.toBe('hidden');

// Open mobile menu first
await wrapper.findByDataTest('ec-mobile-header__menu').trigger('click');
expect(wrapper.element).toMatchSnapshot('before');
expect(document.body.style.overflow).toBe('hidden');

// Close navigation when a menu item is clicked
await wrapper.findByDataTest('my-custom-link').trigger('click');
expect(wrapper.element).toMatchSnapshot('after');
expect(document.body.style.overflow).not.toBe('hidden');
});
});
});
10 changes: 9 additions & 1 deletion src/components/ec-navigation/ec-navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { useScrollLock } from '@vueuse/core';
import { ref, watch } from 'vue';
import EcIcon from '../ec-icon';
import { IconName } from '../ec-icon/types';
Expand All @@ -133,6 +134,13 @@ defineOptions({
inheritAttrs: false,
});
const scrollLockTarget = ref(document.body);
const isLocked = useScrollLock(scrollLockTarget);
watch(isMobileMenuOpen, (newValue) => {
isLocked.value = newValue;
});
withDefaults(defineProps<NavigationProps>(), {
showBrandingLogo: true,
});
Expand Down

0 comments on commit 7b9d34c

Please sign in to comment.