Merge pull request #5137 from Minion3665/private/minion/push-rmmvnkvqyynr

fix(android): match iframe size to visual viewport
This commit is contained in:
Julius Knorr 2025-11-17 11:34:23 +01:00 committed by GitHub
commit aec8c5502d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 13 additions and 23 deletions

View file

@ -23,7 +23,7 @@
opacity: 1; opacity: 1;
} }
#richdocumentsframe { .office-viewer__iframe {
background-color: #fff; background-color: #fff;
width:100%; width:100%;
height: 100vh; height: 100vh;

View file

@ -15,7 +15,7 @@
padding-top: 0; padding-top: 0;
} }
#richdocumentsframe { .office-viewer__iframe {
height: 100%; height: 100%;
position: fixed; position: fixed;
} }

View file

@ -9,7 +9,7 @@ import { getRequestToken } from '@nextcloud/auth'
import { loadState } from '@nextcloud/initial-state' import { loadState } from '@nextcloud/initial-state'
import Config from './services/config.tsx' import Config from './services/config.tsx'
import { getUIDefaults, generateCSSVarTokens, getCollaboraTheme } from './helpers/coolParameters.js' import { getUIDefaults, generateCSSVarTokens, getCollaboraTheme } from './helpers/coolParameters.js'
import { enableScrollLock } from './helpers/safariFixer.js' import { enableScrollLock } from './helpers/mobileFixer.js'
import PostMessageService from './services/postMessage.tsx' import PostMessageService from './services/postMessage.tsx'
import { getCapabilities } from './services/capabilities.ts' import { getCapabilities } from './services/capabilities.ts'
import { import {

View file

@ -6,27 +6,19 @@
let scrollLock = false let scrollLock = false
let intervalHandler let intervalHandler
const isiOS = [ // Workaround for browsers automatically scrolling the body when the hidden input is focussed
'iPad Simulator',
'iPhone Simulator',
'iPod Simulator',
'iPad',
'iPhone',
'iPod',
].includes(navigator.platform) || (navigator.userAgent.includes('Mac') && navigator.maxTouchPoints > 1)
// Workaround for Safari automatically scrolling the body when the hidden input is focussed
const handleScrollReset = () => { const handleScrollReset = () => {
document.documentElement.scrollTop = 0 document.documentElement.scrollTop = 0
document.scrollingElement.scrollTop = 0 document.scrollingElement.scrollTop = 0
} }
// Workaround for Safari to resize the iframe to the proper height // Workaround for mobile browsers to resize the iframe to the visual viewport height
// as 100vh is not the proper viewport height there // as visual viewport area - which includes OSK, say - is not propagated to iframes
// see https://developer.mozilla.org/en-US/docs/Web/API/VisualViewport
const handleResize = () => { const handleResize = () => {
const expectedHeight = window.visualViewport.height ?? document.documentElement.clientHeight const expectedHeight = window.visualViewport.height ?? document.documentElement.clientHeight
const frame = document.getElementById('richdocumentsframe') const frames = document.getElementsByClassName('office-viewer__iframe')
if (frame) { for (const frame of frames) {
frame.style.maxHeight = expectedHeight + 'px' frame.style.maxHeight = expectedHeight + 'px'
} }
const viewer = document.querySelector('.office-viewer') const viewer = document.querySelector('.office-viewer')
@ -36,12 +28,10 @@ const handleResize = () => {
} }
const fixThemAll = () => { const fixThemAll = () => {
if (!isiOS) {
return
}
if (!scrollLock) { if (!scrollLock) {
return return
} }
handleScrollReset() handleScrollReset()
handleResize() handleResize()
} }
@ -49,7 +39,7 @@ const fixThemAll = () => {
const preventDefault = (e) => e.preventDefault() const preventDefault = (e) => e.preventDefault()
export const enableScrollLock = () => { export const enableScrollLock = () => {
if (scrollLock || !isiOS) { if (scrollLock) {
return return
} }
@ -65,7 +55,7 @@ export const enableScrollLock = () => {
} }
export const disableScrollLock = () => { export const disableScrollLock = () => {
if (!scrollLock || !isiOS) { if (!scrollLock) {
return return
} }

View file

@ -99,7 +99,7 @@ import {
import PostMessageService from '../services/postMessage.tsx' import PostMessageService from '../services/postMessage.tsx'
import FilesAppIntegration from './FilesAppIntegration.js' import FilesAppIntegration from './FilesAppIntegration.js'
import { LOADING_ERROR, checkCollaboraConfiguration, checkProxyStatus } from '../services/collabora.js' import { LOADING_ERROR, checkCollaboraConfiguration, checkProxyStatus } from '../services/collabora.js'
import { enableScrollLock, disableScrollLock } from '../helpers/safariFixer.js' import { enableScrollLock, disableScrollLock } from '../helpers/mobileFixer.js'
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { import {
generateUrl, generateUrl,