fix(mobile): bouton mode lecture visible uniquement fichier ouvert (BUG-016)
CI / lint (push) Successful in 1m10s
CI / security (push) Successful in 46s
CI / test (push) Successful in 2m23s
CI / build (push) Successful in 41s
CI / e2e (push) Successful in 10m28s

This commit is contained in:
2026-09-12 22:44:15 -04:00
parent cb07b92543
commit d47fcbf2be
7 changed files with 95 additions and 4 deletions
+34
View File
@@ -603,6 +603,27 @@ function buildReadingControls() {
document.body.appendChild(exit);
}
/** True when the BooksLM assistant panel is expanded on screen. */
function isAssistantOpen() {
const panel = document.querySelector('.bookslm-panel');
return !!(panel && panel.classList.contains('open') && !panel.classList.contains('hidden'));
}
/**
* Show the floating reading-mode button only while a file is open and the
* assistant panel is closed. Without this guard the button floats above the
* full-screen mobile assistant and covers its send button.
*
* Called on init, whenever the content area changes and when the assistant
* opens/closes.
*/
export function updateReadingButtonVisibility() {
const btn = document.getElementById('me-reading-btn');
if (!btn) return;
const fileOpen = !!state.currentPath;
btn.hidden = !fileOpen || isAssistantOpen();
}
// ── Swipe gestures ─────────────────────────────────────────────────────────
function initSwipeGestures() {
@@ -659,6 +680,19 @@ export function initMobileEditor() {
buildReadingControls();
initSwipeGestures();
// Keep the reading button in sync with the current view: visible only when
// a file is open and the assistant is closed.
updateReadingButtonVisibility();
document.addEventListener('bookslm:opened', updateReadingButtonVisibility);
document.addEventListener('bookslm:closed', updateReadingButtonVisibility);
const readingArea = document.getElementById('content-area');
if (readingArea && typeof MutationObserver !== 'undefined') {
new MutationObserver(updateReadingButtonVisibility).observe(readingArea, {
childList: true,
subtree: true,
});
}
const bodyEl = document.getElementById('editor-body');
if (bodyEl) {
initPinchZoom(bodyEl);
+4
View File
@@ -9577,6 +9577,10 @@ body.bookslm-resizing { cursor: ew-resize; user-select: none; }
.me-reading-exit {
display: none;
}
/* Author `display: flex` would otherwise win over the `[hidden]` attribute. */
.me-reading-btn[hidden] {
display: none;
}
@media (max-width: 768px) {
.me-reading-btn {