Add iPadOS detection and iOS detection and adjust styles

We need proper iPadOS detection so that both browsers and DiscourseHub
are covered simultaneously. Our server-side mobile detection causes
an inconsistency between Hub (who gets the "ios-device" class) and
Safari (where that class isn't added).

The frontend capabilities for `isIOS` include both iOS and iPadOS.
This commit is contained in:
Penar Musaraj 2024-10-10 10:16:09 -04:00
parent 6b0092c163
commit 9bb9fdc1e6
No known key found for this signature in database
GPG Key ID: E390435D881FF0F7
5 changed files with 21 additions and 30 deletions

View File

@ -8,5 +8,13 @@ export default {
} else { } else {
html.classList.add("no-touch", "discourse-no-touch"); html.classList.add("no-touch", "discourse-no-touch");
} }
if (caps.isIpadOS) {
html.classList.add("ipados-device");
}
if (caps.isIOS) {
html.classList.add("ios-device");
}
}, },
}; };

View File

@ -3,8 +3,11 @@ import { helperContext } from "discourse-common/lib/helpers";
export default function (element) { export default function (element) {
const caps = helperContext().capabilities; const caps = helperContext().capabilities;
// testing this out, DON NOT COMMIT // disable on iPadOS
if (caps.isIOS) { // hacky, but prevents the composer from being moved off-screen
// when tapping an already focused element
if (caps.isIpadOS) {
return; return;
} }

View File

@ -629,25 +629,11 @@ div.ac-wrap {
box-sizing: border-box; box-sizing: border-box;
} }
// for iPhones .keyboard-visible.ipados-device {
.keyboard-visible.ios-device { #reply-control,
.grippie, #reply-control.fullscreen {
html:not(.fullscreen-composer) & .toggle-fullscreen { z-index: z("ipad-header-nav") + 1;
display: none; bottom: var(--software-keyboard-height);
}
#reply-control {
top: 0px;
&.open {
height: calc(var(--composer-vh, 1vh) * 100);
}
}
}
// probably should use another way to detect iPad
.keyboard-visible.discourse-touch:not(.ios-device) {
#reply-control {
bottom: var(--software-keyboard-bottom-offset);
} }
} }

View File

@ -86,11 +86,6 @@ html.footer-nav-ipad {
padding-bottom: 0; // resets safe-area-inset-bottom padding-bottom: 0; // resets safe-area-inset-bottom
} }
#reply-control,
#reply-control.fullscreen {
z-index: z("ipad-header-nav") + 1;
}
&.docked .d-header-wrap { &.docked .d-header-wrap {
top: var(--footer-nav-height); top: var(--footer-nav-height);
} }

View File

@ -19,6 +19,7 @@
} }
&.open { &.open {
max-height: 100vh;
height: 250px; height: 250px;
&.edit-title { &.edit-title {
height: 100%; height: 100%;
@ -29,11 +30,9 @@
height: 100%; // Android: Reduces composer jumpiness when the keyboard toggles height: 100%; // Android: Reduces composer jumpiness when the keyboard toggles
} }
.keyboard-visible body.ios-safari-composer-hacks &.open { .keyboard-visible.ios-device &.open {
bottom: var(--software-keyboard-height);
height: calc(var(--composer-vh, 1vh) * 100); height: calc(var(--composer-vh, 1vh) * 100);
.reply-area {
padding-bottom: 6px;
}
} }
// Firefox for Android hack // Firefox for Android hack