Skip to content

Commit

Permalink
Fix inability to tap outside modal on mobile
Browse files Browse the repository at this point in the history
This commit addresses touch target size issues on mobile devices by
adjusting modal margins. The larger margin allows for easier interaction
for modal dialogs by tapping outside the modal area on smaller screens.

Key changes:

- Introduce 30px margin on larger screens and 20px on smaller devices
  around modals, adhering to accessibility guidelines.
- Remove `max-height: 90vh;` in favor of consistent vertical margins,
  centralizing the spacing control via the `margin` property.
- Remove `max-height: 90v;` used to display scroll-bars as the vertical
  margin is now handled by `margin` property in single place.
  • Loading branch information
undergroundwires committed Apr 15, 2024
1 parent f3571ab commit cb144ae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/presentation/components/Shared/Modal/ModalContainer.vue
Expand Up @@ -9,7 +9,6 @@
@click="onBackgroundOverlayClick"
/>
<ModalContent
class="modal-content"
:show="isOpen"
@transitioned-out="onContentTransitionedOut"
>
Expand Down Expand Up @@ -138,6 +137,8 @@ export default defineComponent({
</script>

<style scoped lang="scss">
@use "@/presentation/assets/styles/main" as *;
.modal-container {
position: fixed;
box-sizing: border-box;
Expand Down
13 changes: 12 additions & 1 deletion src/presentation/components/Shared/Modal/ModalContent.vue
Expand Up @@ -59,7 +59,7 @@ $modal-content-offset-upward: $spacing-absolute-x-large;
@mixin scrollable() {
overflow-y: auto;
max-height: 90vh;
max-height: 100%;
}
.modal-content-wrapper {
Expand All @@ -74,6 +74,17 @@ $modal-content-offset-upward: $spacing-absolute-x-large;
right: 0;
bottom: 0;
left: 0;
// Margin around modal content ensures visual comfort and consistency across devices.
// It provides:
// - A visually comfortable space preventing a claustrophobic feeling, especially on smaller screens.
// - Consistent appearance on various screen sizes by using absolute spacing.
// - Focus on the modal by dimming the background and emphasizing the task.
// - Sufficient space on small devices for users to tap outside and close the modal.
margin: $spacing-absolute-xx-large;
@media screen and (max-width: $media-screen-small-width) {
margin: $spacing-absolute-x-large; // Google and Apple recommend at least 44x44px for touch targets
}
}
.modal-content-content {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/no-unintended-layout-shifts.cy.ts
Expand Up @@ -19,7 +19,7 @@ describe('Layout stability', () => {
.contains('button', 'Privacy')
.click();
cy
.get('.modal-content')
.get('.modal-content-content')
.should('be.visible');
});
});
Expand Down

0 comments on commit cb144ae

Please sign in to comment.