Fix inability to tap outside modal on mobile

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.
This commit is contained in:
undergroundwires
2024-04-15 09:21:31 +02:00
parent f3571abeaf
commit cb144ae472
3 changed files with 15 additions and 3 deletions

View File

@@ -9,7 +9,6 @@
@click="onBackgroundOverlayClick" @click="onBackgroundOverlayClick"
/> />
<ModalContent <ModalContent
class="modal-content"
:show="isOpen" :show="isOpen"
@transitioned-out="onContentTransitionedOut" @transitioned-out="onContentTransitionedOut"
> >
@@ -138,6 +137,8 @@ export default defineComponent({
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@use "@/presentation/assets/styles/main" as *;
.modal-container { .modal-container {
position: fixed; position: fixed;
box-sizing: border-box; box-sizing: border-box;

View File

@@ -59,7 +59,7 @@ $modal-content-offset-upward: $spacing-absolute-x-large;
@mixin scrollable() { @mixin scrollable() {
overflow-y: auto; overflow-y: auto;
max-height: 90vh; max-height: 100%;
} }
.modal-content-wrapper { .modal-content-wrapper {
@@ -74,6 +74,17 @@ $modal-content-offset-upward: $spacing-absolute-x-large;
right: 0; right: 0;
bottom: 0; bottom: 0;
left: 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 { .modal-content-content {

View File

@@ -19,7 +19,7 @@ describe('Layout stability', () => {
.contains('button', 'Privacy') .contains('button', 'Privacy')
.click(); .click();
cy cy
.get('.modal-content') .get('.modal-content-content')
.should('be.visible'); .should('be.visible');
}); });
}); });