Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

Mobile keyboard: hide audio player + bottom nav while typing so input/content get the space above the keyboard (instead of squishing everything)

Murtaza Nasirb1afb3cbbd67
diff --git a/static/css/styles.css b/static/css/styles.css
index 1b6bdd9a..596b713e 100644
--- a/static/css/styles.css
+++ b/static/css/styles.css
@@ -405,6 +405,18 @@ main {
height: var(--app-height, 100dvh);
}
+/* When a text field is focused (keyboard up, .keyboard-open set on <html> by
+ the head script), hide the mobile audio player + bottom tab nav. They're not
+ useful while typing and would only steal the limited space above the
+ keyboard; the chat input + content take that space instead. Mobile only —
+ these elements don't render on desktop anyway. */
+@media (max-width: 1023px) {
+ html.keyboard-open [data-mobile-player],
+ html.keyboard-open [data-mobile-bottom-nav] {
+ display: none !important;
+ }
+}
+
/* Sidebar styles with flexible height */
.sidebar-container {
height: 100%; /* Use relative height */
diff --git a/templates/index.html b/templates/index.html
index 7179b0d9..70124c08 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -18,6 +18,23 @@
apply();
if (vv) { vv.addEventListener('resize', apply); vv.addEventListener('scroll', apply); }
window.addEventListener('orientationchange', function () { setTimeout(apply, 250); });
+
+ // While a text field is focused (keyboard up), flag <html> so CSS can
+ // hide the mobile player + bottom nav: they're not useful while typing
+ // and only steal the limited space above the keyboard. (Tapping them
+ // would dismiss the keyboard anyway.)
+ function isTextField(el) {
+ if (!el || !el.tagName) return false;
+ var tag = el.tagName.toLowerCase();
+ if (tag === 'textarea') return true;
+ if (tag === 'input') {
+ var t = (el.type || 'text').toLowerCase();
+ return ['text', 'search', 'email', 'url', 'tel', 'password', 'number'].indexOf(t) !== -1;
+ }
+ return el.isContentEditable === true;
+ }
+ document.addEventListener('focusin', function (e) { if (isTextField(e.target)) root.classList.add('keyboard-open'); });
+ document.addEventListener('focusout', function (e) { if (isTextField(e.target)) root.classList.remove('keyboard-open'); });
})();
</script>
<meta name="csrf-token" content="{{ csrf_token() }}">