Skip to content

Commit afee796

Browse files
JohnMcLearclaude
andauthored
fix(7696): scrollable settings popup on short viewports (#7703)
* fix(7696): make settings popup scroll on short viewports Move max-height + overflow:auto out of the mobile-only media query and onto the base .popup-content rule so the Settings popup (and other popups) gain a scrollbar instead of cropping items off-screen when the window is short. Pad-wide Settings is the worst offender because it adds a second column of controls plus a Delete pad button. Adds a Playwright regression test that verifies the popup is scrollable and the Delete pad button is reachable at a 900x500 viewport. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(7696): float nice-select dropdowns above scrollable popups Qodo flagged that making .popup-content a scroll container clips absolutely-positioned descendants — so the Settings popup's font and language dropdowns can be truncated when their list extends past the popup's scroll bounds on short viewports. Mirror the existing toolbar workaround: when a nice-select sits inside .popup-content, switch the list to position:fixed (CSS) and place it with viewport-relative coordinates from getBoundingClientRect (JS), respecting the existing reverse class for upward-opening lists. Also relax the regression test per Qodo: drop the brittle scrollHeight > clientHeight assertion in favour of asserting the popup declares overflow-y:auto and proving Delete pad is initially off-screen, then reachable via scroll. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(7696): nice-select reverse list disappeared in scrolled popup When a nice-select inside a popup-content scroll container sits in the lower half of the viewport, the JS adds the .reverse class so the list opens upward. The default .reverse rule sets bottom: calc(100% + 5px), which is fine when the list is position:absolute relative to its parent — but with the position:fixed treatment the popup branch uses, that percentage resolves against the viewport and pushes the list ~100vh above the screen, so it appears not to open at all until you scroll to the bottom of the popup (where .reverse no longer triggers). Override the rule for both .toolbar and .popup so .reverse drops back to bottom: auto and JS-set `top` controls placement, with a JS belt-and- braces also setting `bottom: auto` inline. Adds a Playwright regression test that scrolls the settings popup to the bottom, opens the Pad-wide font dropdown, and asserts the list is both visible and inside the viewport. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 85c941f commit afee796

4 files changed

Lines changed: 96 additions & 5 deletions

File tree

src/static/css/pad/form.css

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,23 @@ select, .nice-select {
132132
bottom: calc(100% + 5px);
133133
top: auto;
134134
}
135-
.toolbar .nice-select .list {
135+
.toolbar .nice-select .list,
136+
/* Popups are scroll containers (see popup.css), which would otherwise clip the
137+
absolutely-positioned dropdown list. Float it above the popup with fixed
138+
positioning, matching how the toolbar dropdowns escape their container. */
139+
.popup .nice-select .list {
136140
position: fixed;
137141
top: auto;
138142
left: auto;
139143
}
144+
/* The default .reverse rule above sets bottom: calc(100% + 5px) so an
145+
absolutely-positioned list opens upward inside its parent. Once the list is
146+
position:fixed, that percentage resolves against the viewport instead and
147+
would push the list off-screen, so we let JS place it via `top` only. */
148+
.toolbar .nice-select.reverse .list,
149+
.popup .nice-select.reverse .list {
150+
bottom: auto;
151+
}
140152
.nice-select .list:hover .option:not(:hover) {
141153
background-color: transparent !important;
142154
}

src/static/css/pad/popup.css

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@
3030
background: #f7f7f7;
3131
min-width: min(300px, 90vw);
3232
max-width: min(600px, 95vw);
33+
/* Constrain height so popups (notably Settings with Pad-wide Settings
34+
enabled) scroll instead of cropping items off-screen on short windows.
35+
Fixes #7696. */
36+
max-height: calc(100vh - 20px);
37+
overflow-y: auto;
38+
}
39+
40+
/* Chat manages its own scroll and floats author-colour pickers outside the
41+
popup, so it must not become a scroll container. */
42+
.popup#users .popup-content {
43+
overflow: visible;
3344
}
3445
.popup input[type=text] {
3546
width: 100%;
@@ -76,10 +87,6 @@
7687
}
7788
.popup-content {
7889
max-height: 80vh;
79-
overflow: auto;
80-
}
81-
.popup#users .popup-content {
82-
overflow: visible;
8390
}
8491
}
8592
/* Move popup to the bottom, except popup linked to left toolbar, like hyperklink popup */

src/static/js/vendors/nice-select.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,25 @@
123123
}
124124
$dropdown.find('.list').css('max-height', $maxListHeight + 'px');
125125

126+
// Popups are scroll containers (since #7696) which would clip the
127+
// absolutely-positioned dropdown list. The list is repositioned with
128+
// `position: fixed` (see form.css) so it floats above the popup; we
129+
// need viewport-relative coordinates here. Done after the reverse
130+
// class is decided so we know which side of the dropdown to anchor.
131+
if ($dropdown.closest('.toolbar').length === 0
132+
&& $dropdown.closest('.popup-content').length > 0) {
133+
var rect = $dropdown[0].getBoundingClientRect();
134+
var $list = $dropdown.find('.list');
135+
$list.css('left', rect.left);
136+
$list.css('min-width', $dropdown.outerWidth() + 'px');
137+
// Clear .reverse's `bottom: calc(100% + 5px)` — with position:fixed
138+
// it would resolve against the viewport and push the list offscreen.
139+
$list.css('bottom', 'auto');
140+
$list.css('top', $dropdown.hasClass('reverse')
141+
? rect.top - $maxListHeight - 5
142+
: rect.bottom);
143+
}
144+
126145
} else {
127146
$dropdown.trigger('focus');
128147
}

src/tests/frontend-new/specs/pad_settings.spec.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,59 @@ test.describe('creator-owned pad settings', () => {
167167
await context2.close();
168168
});
169169

170+
// #7696: on a short viewport the settings popup must scroll so items in
171+
// Pad-wide Settings (notably "Delete pad") stay reachable instead of being
172+
// cropped off-screen with no scrollbar.
173+
test('settings popup stays scrollable when the viewport is short', async ({page}) => {
174+
await page.setViewportSize({width: 900, height: 500});
175+
await goToNewPad(page);
176+
await showSettings(page);
177+
178+
const popupContent = page.locator('#settings > .popup-content');
179+
await expect(popupContent).toBeVisible();
180+
await expect(page.locator('#pad-settings-section')).toBeVisible();
181+
182+
// The popup must declare scrollable overflow (otherwise the previous bug
183+
// recurs even if content happens to fit by coincidence).
184+
await expect(popupContent).toHaveCSS('overflow-y', 'auto');
185+
186+
// Delete pad sits at the bottom of Pad-wide Settings; on a short viewport
187+
// it starts off-screen and must become reachable by scrolling the popup.
188+
const deletePad = page.locator('#delete-pad');
189+
await expect(deletePad).not.toBeInViewport();
190+
await deletePad.scrollIntoViewIfNeeded();
191+
await expect(deletePad).toBeInViewport();
192+
});
193+
194+
// #7696 follow-up: the Pad-wide font/language nice-select dropdowns sit
195+
// near the bottom of the popup, so opening one triggers the .reverse path
196+
// (open upward). Floating the list with position:fixed must not pick up
197+
// the default `.reverse { bottom: calc(100% + 5px) }` rule, which would
198+
// resolve against the viewport and place the list off-screen.
199+
test('Pad-wide font dropdown opens visibly when popup is scrolled to bottom', async ({page}) => {
200+
await page.setViewportSize({width: 900, height: 500});
201+
await goToNewPad(page);
202+
await showSettings(page);
203+
204+
// Force the font dropdown into the lower portion of the viewport so
205+
// .reverse triggers and the list opens upward.
206+
await page.locator('#settings > .popup-content').evaluate((el) => {
207+
el.scrollTop = el.scrollHeight;
208+
});
209+
210+
const fontDropdown = page.locator('#padsettings-viewfontmenu + .nice-select');
211+
await expect(fontDropdown).toBeInViewport();
212+
213+
await fontDropdown.click();
214+
const list = fontDropdown.locator('.list');
215+
await expect(list).toBeVisible();
216+
await expect(list).toBeInViewport();
217+
218+
// The first option must be reachable so users can actually pick a font.
219+
await fontDropdown.locator('.option').first().click();
220+
await expect(fontDropdown).not.toHaveClass(/open/);
221+
});
222+
170223
// #7592: ticking "Disable chat" must visibly disable the dependent
171224
// "Chat always on screen" / "Show Chat and Users" toggles, not just
172225
// make the underlying inputs non-interactive.

0 commit comments

Comments
 (0)