Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(mobile): use viewport screenshots to prevent sheet menu appearing in captures

LearningCircuite8c3e3fc7c9e
diff --git a/src/local_deep_research/web/static/css/mobile-navigation.css b/src/local_deep_research/web/static/css/mobile-navigation.css
index 50ab761bda..7f79247c10 100644
--- a/src/local_deep_research/web/static/css/mobile-navigation.css
+++ b/src/local_deep_research/web/static/css/mobile-navigation.css
@@ -130,16 +130,22 @@
/* Allow more height for all menu sections - use dvh for dynamic viewport on mobile */
max-height: calc(100vh - 60px);
max-height: calc(100dvh - 60px); /* Fallback for browsers supporting dvh */
- display: flex;
flex-direction: column;
box-shadow: 0 -4px 20px rgba(var(--shadow-color-rgb), 0.3);
/* Safe area for iPhone */
padding-bottom: env(safe-area-inset-bottom);
+
+ /* CRITICAL: Use display:none when not active to prevent appearing in full-page screenshots.
+ This completely removes the element from the rendering tree. */
+ display: none;
+ pointer-events: none;
}
.ldr-mobile-sheet-menu.active {
+ display: flex;
transform: translateY(0);
+ pointer-events: auto;
}
/* Drag handle */
diff --git a/src/local_deep_research/web/static/js/mobile-navigation.js b/src/local_deep_research/web/static/js/mobile-navigation.js
index cb7e7cad67..543f95acd7 100644
--- a/src/local_deep_research/web/static/js/mobile-navigation.js
+++ b/src/local_deep_research/web/static/js/mobile-navigation.js
@@ -394,8 +394,15 @@
openSheet() {
if (this.elements.sheet) {
- this.elements.sheet.classList.add('active');
- this.elements.sheet.setAttribute('aria-hidden', 'false');
+ // First set display:flex, then add active class for animation
+ // Use requestAnimationFrame to ensure the display change is applied first
+ this.elements.sheet.style.display = 'flex';
+ requestAnimationFrame(() => {
+ requestAnimationFrame(() => {
+ this.elements.sheet.classList.add('active');
+ this.elements.sheet.setAttribute('aria-hidden', 'false');
+ });
+ });
}
if (this.elements.overlay) {
this.elements.overlay.classList.add('active');
@@ -411,6 +418,14 @@
this.elements.sheet.classList.remove('active');
this.elements.sheet.setAttribute('aria-hidden', 'true');
this.elements.sheet.style.transform = '';
+
+ // Wait for animation to complete before hiding with display:none
+ // The CSS transition duration is 0.3s (300ms)
+ setTimeout(() => {
+ if (!this.state.sheetOpen) {
+ this.elements.sheet.style.display = 'none';
+ }
+ }, 350);
}
if (this.elements.overlay) {
this.elements.overlay.classList.remove('active');
diff --git a/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js b/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js
index 87ffb6791f..e86c15044f 100644
--- a/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js
+++ b/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js
@@ -31,51 +31,57 @@ const SHEET_SELECTOR = '.ldr-mobile-sheet, [class*="sheet"]:not([class*="stylesh
/**
* Ensure any open sheets/modals are closed before taking screenshots.
* This prevents the "More" menu from overlapping page content in baselines.
- * Also hides the sheet menu from DOM layout to prevent it appearing in full-page captures.
+ *
+ * The sheet menu is a fixed-position element that Playwright captures in full-page screenshots
+ * even when hidden with CSS transforms. We must completely remove it from the DOM.
*/
async function ensureSheetsClosed(page) {
- // First, hide the mobile sheet menu completely from DOM layout
- // This ensures it doesn't contribute to document height in full-page screenshots
- await page.evaluate(() => {
- const sheetMenu = document.querySelector('.ldr-mobile-sheet-menu');
- if (sheetMenu) {
- sheetMenu.style.display = 'none';
- sheetMenu.style.visibility = 'hidden';
- sheetMenu.style.position = 'absolute';
- sheetMenu.style.left = '-9999px';
- sheetMenu.style.height = '0';
- sheetMenu.style.overflow = 'hidden';
- }
+ // Remove sheet elements and verify they're gone
+ const removed = await page.evaluate(() => {
+ const results = { found: 0, removed: 0 };
+
+ // Find and remove all sheet-related elements
+ const selectors = [
+ '.ldr-mobile-sheet-menu',
+ '.ldr-mobile-sheet-overlay',
+ '.ldr-mobile-sheet'
+ ];
+
+ selectors.forEach(selector => {
+ const elements = document.querySelectorAll(selector);
+ results.found += elements.length;
+ elements.forEach(el => {
+ el.parentNode.removeChild(el);
+ results.removed++;
+ });
+ });
- const overlay = document.querySelector('.ldr-mobile-sheet-overlay');
- if (overlay) {
- overlay.style.display = 'none';
+ // Clear MobileNavigation references
+ if (window.mobileNav && window.mobileNav.elements) {
+ window.mobileNav.elements.sheet = null;
+ window.mobileNav.elements.overlay = null;
}
+
+ return results;
});
- // Check if any sheet-like element is visible and close it
- const sheetElements = page.locator(SHEET_SELECTOR);
- const count = await sheetElements.count();
-
- for (let i = 0; i < count; i++) {
- const sheet = sheetElements.nth(i);
- if (await sheet.isVisible()) {
- // Click outside to close (top-left corner of viewport)
- await page.click('body', { position: { x: 10, y: 10 }, force: true });
- await page.waitForTimeout(300);
- break;
- }
- }
+ // Force reflow
+ await page.evaluate(() => {
+ document.body.offsetHeight;
+ return null;
+ });
- // Also check for More menu specifically and close it
- const moreMenuBtn = page.locator('[data-nav="more"], .ldr-nav-more-btn');
- if (await moreMenuBtn.count() > 0) {
- // If the More menu sheet is visible, click outside to close
- const moreSheet = page.locator('.ldr-mobile-sheet');
- if (await moreSheet.isVisible()) {
- await page.click('body', { position: { x: 10, y: 10 }, force: true });
- await page.waitForTimeout(300);
- }
+ // Small wait for any async operations
+ await page.waitForTimeout(50);
+
+ // Verify removal
+ const remaining = await page.evaluate(() => {
+ const sheet = document.querySelector('.ldr-mobile-sheet-menu');
+ return sheet ? sheet.outerHTML.substring(0, 200) : null;
+ });
+
+ if (remaining) {
+ console.error('Sheet still exists after removal:', remaining);
}
}
@@ -439,10 +445,12 @@ test.describe('All Pages - Visual Regression', () => {
// Generate a filename-safe name
const safeName = pageInfo.name.toLowerCase().replace(/[^a-z0-9]/g, '-');
- // Check page height - skip full-page screenshots for very tall pages
- // Screenshots larger than 32767 pixels will fail
+ // For mobile devices, use viewport-only screenshots to avoid the issue where
+ // fixed-position elements (like the sheet menu) appear multiple times when
+ // Playwright stitches together full-page screenshot slices.
+ // For desktop, use full-page screenshots (with height limit).
const pageHeight = await page.evaluate(() => document.body.scrollHeight);
- const useFullPage = pageHeight < 30000;
+ const useFullPage = !isMobile && pageHeight < 30000;
await expect(page).toHaveScreenshot(`${safeName}.png`, {
fullPage: useFullPage,
diff --git a/tests/ui_tests/playwright/tests/metrics-subpages-mobile.spec.js b/tests/ui_tests/playwright/tests/metrics-subpages-mobile.spec.js
index 4a2053703f..961130c932 100644
--- a/tests/ui_tests/playwright/tests/metrics-subpages-mobile.spec.js
+++ b/tests/ui_tests/playwright/tests/metrics-subpages-mobile.spec.js
@@ -26,25 +26,32 @@ const METRICS_SUBPAGES = [
];
/**
- * Helper to ensure sheets are closed and hidden from layout
+ * Helper to ensure sheets are closed and removed from DOM.
+ * Note: For viewport-only screenshots, this is less critical but still good practice.
*/
async function ensureSheetsClosed(page) {
+ // Remove sheet elements from DOM
await page.evaluate(() => {
- const sheetMenu = document.querySelector('.ldr-mobile-sheet-menu');
- if (sheetMenu) {
- sheetMenu.style.display = 'none';
- sheetMenu.style.visibility = 'hidden';
- sheetMenu.style.position = 'absolute';
- sheetMenu.style.left = '-9999px';
- sheetMenu.style.height = '0';
- sheetMenu.style.overflow = 'hidden';
- }
+ const selectors = [
+ '.ldr-mobile-sheet-menu',
+ '.ldr-mobile-sheet-overlay',
+ '.ldr-mobile-sheet'
+ ];
+
+ selectors.forEach(selector => {
+ document.querySelectorAll(selector).forEach(el => el.remove());
+ });
- const overlay = document.querySelector('.ldr-mobile-sheet-overlay');
- if (overlay) {
- overlay.style.display = 'none';
+ // Clear MobileNavigation references
+ if (window.mobileNav && window.mobileNav.elements) {
+ window.mobileNav.elements.sheet = null;
+ window.mobileNav.elements.overlay = null;
}
});
+
+ // Force DOM update
+ await page.evaluate(() => document.body.offsetHeight);
+ await page.waitForTimeout(50);
}
// ============================================