Commit c3150d1
committed
fix(android): match iframe size to visual viewport
I've been testing Collabora Online with Nextcloud on Android, and I've
noticed some content displaying behind the onscreen keyboard as follows:
There are two viewports on the web, the "visual" viewport (what you
actually see) and the "layout" viewport (how the browser draws the
page). The onscreen keyboard popping up used to resize the layout
viewport. In newer Android versions, the onscreen keyboard by default
resizes the visual viewport rather than the layout viewport.
Unfortunately, the visual viewport isn't propagated through iframes, as
per MDN docs which state:
> Only the top-level window has a visual viewport that's distinct from
> the layout viewport. Therefore, it's generally only the VisualViewport
> object of the top-level window that's useful. For an <iframe>, visual
> viewport metrics like VisualViewport.width always correspond to layout
> viewport metrics like document.documentElement.clientWidth.
(Quote from [VisualViewport page on MDN Docs][VV], by Mozilla
Contributors under [CC-BY-SA v2.5][VVLICENSE])
[VV]: https://developer.mozilla.org/en-US/docs/Web/API/VisualViewport
[VVLICENSE]: https://creativecommons.org/licenses/by-sa/2.5/
This leads to Collabora Online seeing the viewport as the size of its
iframe in all cases. When the onscreen keyboard is up, this causes some
parts of the app (the bottom toolbar) to be hidden as they are behind
the keyboard. The intention is for this toolbar to instead float above
the keyboard.
I've done some investigation and this would be a problem on
iOS/iPadOS too... it would be, except Julius has already written
code to fix it (thanks Julius!). The code I'm talking about was
in `src/helpers/safariFixer.js`, part of its job was to resize the
richdocuments frame in place of the browser. It was previously gated to
only running on iOS, but we can make it broader so it encompasses all
browsers - including those running on Android devices.
If we change that code to fix things other than Safari, the name no
longer makes sense. Therefore, let's rename it to `mobileFixer.js` as
well
Finally, it's worth noting that this doesn't work in every browser
I tested. Notably [Fennec][FENNEC] doesn't appear to correctly
resize the visual viewport so this fix doesn't work over there.
Notwithstanding, this fix does appear to work in both Play Store
Chrome and Play Store Firefox which is a lot better than not
working at all. Potential fixes for Fennec were considered possibly
too risky: we could set a meta tag with `name="viewport"` and
`content="interactive-widget=resizes-content"` but this would need
to be set even when richdocuments isn't in use (or isn't installed!).
Therefore, we'll have to cope with the state of things as they are for
now...
[FENNEC]: https://f-droid.org/en/packages/org.mozilla.fennec_fdroid/
Signed-off-by: Skyler Grey <[email protected]>1 parent 2663786 commit c3150d1
3 files changed
+12
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
Lines changed: 10 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | 40 | | |
43 | 41 | | |
44 | 42 | | |
45 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
52 | | - | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| |||
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | | - | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| |||
0 commit comments