• Stars
    star
    109
  • Rank 319,077 (Top 7 %)
  • Language
    JavaScript
  • Created over 6 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Fullscreen mobile modal. How hard can it be?

Post on dev.to.

Imagine you need to implement a mobile-friendly form, beyond traditional inputs you need to implement fullscreen infinite calendar and a fullscreen combo box. Let's talk about "fullscreen". How hard you expect it would be? Should be not hard - just use fullscreen div with z-index and fixed position. Right? That what I thought.

Attempt number 1

Online example

Let's use div which will cover all screen

.FullScreenOne {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  top: 0;
  z-index: 1;
  background: #fff;
}

It works, except user can use Tab (or โŒƒ and โŒ„ in iOS) to move cursor out of modal.

Attempt number 2

Online example

Use Reach Dialog (in addition to previous solution). Dialog will set aria-hidden on all nodes at the document.body root except for the currently active dialog. This traps the virtual cursor inside the dialog.

Side note: I tried react-focus-lock, but it doesn't work in iOS (I mean for โŒƒ and โŒ„).

It works, except when the user wants to scroll the content of the modal, but instead, they will scroll content behind the modal.

Attempt number 3

Online example

Use ScrollLocky (in addition to previous solution). ScrollLocky blocks any interactions with the rest of a page with the help of react-locky and position: relative on the body.

It works, except when the user scrolls down and bottom chrome of the Mobile Safari get's hidden, but later it is possible to trigger the appearance of bottom chrome and part of the modal will be hidden.

Attempt number 4

Online example

Use mobile-safari-fullscreen (in addition to previous solution). It will always force to show the bottom of browser chrome when modal is opened.

Side note: WindowSize can be used instead mobile-safari-fullscreen. I would say this is the preferred solution, this demo is more to show how much edge case is possible.

<WindowSize>
  {({ height }) => (
    <ul style={{ height }}>
      <li />
    </ul>
  )}
</WindowSize>

Conclusion

This kind of small details is what makes frontend development hard and interesting same time. If you liked this post read my post about the UX of images on the web.

PS Different browser have the different behavior of focus. The most noticeable is Mobile Safari which doesn't allow to focus on links and buttons ยฏ\_(ใƒ„)_/ยฏ.

Check out this GitHub repo for the full code for this post.

Follow me on twitter and github.

More Repositories

1

react-snap

๐Ÿ‘ป Zero-configuration framework-agnostic static prerendering for SPAs
JavaScript
5,049
star
2

react-ideal-image

๐Ÿ–ผ๏ธ An Almost Ideal React Image Component
JavaScript
3,273
star
3

package.json

๐Ÿ—ƒ๏ธ package.json fields explained
951
star
4

css-in-js-101

๐Ÿ’ˆ CSS-in-JS 101: All you need to know
249
star
5

type-o-rama

๐Ÿ‘พ JS type systems interportability
243
star
6

programming-languages-genealogical-tree

Programming languages genealogical tree
231
star
7

typescript-monorepo

HTML
153
star
8

jekyll-press

๐Ÿšจ [deprecated] Minifier plugin for jekyll. Minifies all html, js, css files. Simple just drop it in solution. No Java required
Ruby
149
star
9

write-you-a-programming-language

List of small programming languages that you can implement in a relatively small amount of time for educational purposes.
99
star
10

guide-to-async-components

๐Ÿ“– Guide To JavaScript Async Components
79
star
11

diamondback-ruby

โ›‘ Fork of diamondback-ruby
Ruby
70
star
12

awesome-hiring-process

Collection of links and ideas about the hiring process in the IT industry
58
star
13

ruby-json-benchmark

Ruby json benchmark
Ruby
36
star
14

html_press

๐Ÿšจ [deprecated] Ruby gem for compressing html
Ruby
35
star
15

pragmatic-types

Small practical guide on Flow and TypeScript for JavaScript developers
33
star
16

jshintrb

๐Ÿšจ [deprecated] Ruby wrapper for JSHint
Ruby
31
star
17

mobile-safari-fullscreen

Fix for Mobile Safari fullscreen issue
JavaScript
23
star
18

ruby-memory-issues

๐Ÿฒ Ruby Memory Issues and Where to Find Them
22
star
19

the-button

JavaScript
17
star
20

react-accessible-accordion

Accessible React accordion component
JavaScript
15
star
21

awesome-vscode-dev-containers

A curated list of VS Code Containers
15
star
22

rb-fchange

๐Ÿšจ [deprecated] Gem which uses native windows methods for watching changes of file system
Ruby
15
star
23

d3-tube

D3 implementation of tube map
JavaScript
14
star
24

main-module-browser-test

Experiment
JavaScript
12
star
25

jekyll_oembed

๐Ÿšจ [deprecated] Jekyll plugin to embed objects with the help of oEmbed. Simple liquid tag
Ruby
12
star
26

html_minifier

Ruby wrapper for kangax html-minifier
JavaScript
11
star
27

dev.wtf

HTML
10
star
28

headless-cms-comparison

JavaScript
9
star
29

the-history-of-frontend-development

Current state of frontend development is controversial. How we got here?
9
star
30

rb-notifu

๐Ÿšจ [deprecated] Notification system for windows. Trying to be Growl
Ruby
8
star
31

social_detector

Detect if visitors are logged into social networks
Ruby
8
star
32

sqip.macro

Webpack sqip-loader implemented as babel-plugin-macros
JavaScript
8
star
33

webpack-comment-import.macro

JavaScript
7
star
34

css-modules-components

styled-components for CSS Modules
JavaScript
7
star
35

postgresql-experiment

JavaScript
6
star
36

css_press

๐Ÿšจ [deprecated] Ruby gem for compressing CSS
Ruby
6
star
37

jBar2

jBar is a simple and lightweight jQuery notification (call to action) banner
JavaScript
4
star
38

useful-react-snippets

TypeScript
4
star
39

tree-sitter-wasm

Shell
4
star
40

react-async-issue

JavaScript
3
star
41

unstyled-components

styled-components based on React's style prop
JavaScript
3
star
42

react-lingui-example

JavaScript
3
star
43

github-issues

Github issues
3
star
44

react-fsm-example

JavaScript
3
star
45

react-simple-country-select

JavaScript
3
star
46

submodule

Small gem to simplify building process of gems with git submodules. Tended to be used for ruby gems which wrap js libraries or another assets
Ruby
2
star
47

zoos

Zoo is an attempt to classify things.
2
star
48

stereobooster.github.io

CSS
2
star
49

wisp

Mirror of https://hg.sr.ht/~arnebab/wisp
Scheme
2
star
50

readme

About me and my open-source work
2
star
51

parsing-with-derivalives

JavaScript
2
star
52

cs-video

Computer science videos
2
star
53

puma-benchmarks

Ruby
2
star
54

small-bits

Small bits of web UX
JavaScript
1
star
55

docker-reasonml

Dockerfile
1
star
56

waypoint-bug-report

waypoint-bug-report
JavaScript
1
star
57

react-router-redux-example

JavaScript
1
star
58

natural_sort-pgxn

Makefile
1
star
59

art_typograf

Ruby wrapper for typograf.artlebedev.ru webservice
Ruby
1
star
60

crystal-lisp

Crystal
1
star
61

main-module-browser

1
star
62

explain-you-mysql

JavaScript
1
star
63

loadable-components.macro

JavaScript
1
star
64

jekyll-seo-lint

Jekyll plugin to validate metadata provided in front matter and in configuration
Ruby
1
star
65

jevix

mirror of http://jevix.googlecode.com/svn/
PHP
1
star
66

jekyll_press

moved to https://github.com/stereobooster/jekyll-press
Ruby
1
star
67

react-ts-experiment

TypeScript
1
star