Repository navigation
Keep Windows search inputs' 24px target spacing - #19907
Conversation
Windows lifts search boxes 1px (#19163), which put each input's center 11.5px below the toolbar row above instead of 12.5px. Where a button sits directly above, as Environment's List/Grid view menu does, axe-core's target-size rule reported 23px of clear space instead of 24px. On Windows the inputs now reach 2px lower, over the box's bottom gap and border, and are padded by the same amount, so they are 17px tall instead of 15px with their centers back 12.5px down and their text unmoved. Addresses #19786.
The first focus pads a search input across its box (fixFocusRectangle), which assumes content-box sizing. Under the border-box sizing added for the 24px spacing, that padding came out of the input's width: a focused Environment search input was 72px wide in a 121px box. Extend the input with bottom padding alone instead, which keeps it 17px tall, and test the focused width. Run the Windows test's axe scan through AxeBuilder's legacy mode instead of injecting axe-core by hand. Addresses #19786.
SuggestBox opens its suggestions at the input's bottom edge, which the Windows search inputs' new 2px bottom padding moved 2px lower: the Go to file/function list opened 3px below the box instead of 1px. Give search widgets' suggestion popups a class and, on Windows, a 1px top margin in place of the 3px all suggestion popups have. Addresses #19786.
Scan and check the focused width of the main toolbar's search box as well as Environment's, assert bounding boxes before reading them, and blur the input afterwards so later tests don't start with focus in a search box. Addresses #19786.
Open a file with a known function, type its name into Go to file/function, and expect the suggestion popup 1px below the search box. With the popup's old 3px margin it opens 3.3px below at 150% scaling. Addresses #19786.
| } | ||
|
|
||
| test.describe('Toolbar target size (#19786)', () => { | ||
| const sandbox = useSuiteSandbox(); |
There was a problem hiding this comment.
Nit: useSuiteSandbox() at the top of the describe registers its beforeAll for every test in the file, but only the @windows_only popup test reads sandbox.dir. On a Server run the three @server_only tests now run createSandbox (a console setwd()) first, and fail in beforeAll if its marker poll times out. Suggest moving the popup test and useSuiteSandbox() into a nested test.describe.
There was a problem hiding this comment.
Fixed in f4a0703: the popup test and useSuiteSandbox() are in a nested test.describe('Windows search suggestions'), so the @server_only tests no longer run the sandbox setup.
| const list = await popup.boundingBox(); | ||
| expect(box, 'search box').not.toBeNull(); | ||
| expect(list, 'suggestion popup').not.toBeNull(); | ||
| expect(list!.y - (box!.y + box!.height), 'gap below the search box').toBeCloseTo(1, 0); |
There was a problem hiding this comment.
Nit: toBeCloseTo(1, 0) allows ±0.5px. GWT places the popup at integer pixels from a box whose position is fractional at 125%/150% (the old-margin figure in the PR body is 3.3px, so 0.3px of rounding is already there). A scale that wasn't tried, such as 175%, could land outside the tolerance with correct CSS. A range that separates 1px from the old 3px would be safer, e.g. greater than 0 and less than 2.
There was a problem hiding this comment.
Fixed in f4a0703: the gap must be greater than 0 and less than 2. It passes at 100%, 125%, 150%, 175% and 200% scaling.
| await expect(page.locator('body.windows'), 'body has the windows class').toHaveCount(1); | ||
| try { | ||
| // A first focus stretches the input across its box by padding it. | ||
| for (const widget of SEARCH_WIDGETS) { |
There was a problem hiding this comment.
Nit: the padding rule also changes FindTextBox inputs (Find in Topic, the editor's Find/Replace bar, FindBar), which use searchBoxContainer2 and their own fixFocusRectangle call, but both Windows tests only measure the two SearchWidget boxes. Consider adding Help's Find in Topic input to this loop and scan.
There was a problem hiding this comment.
Fixed in f4a0703: the Windows spacing test opens help("mean") and adds Find in Topic to the focused-width loop and the axe scan. It passes at the same five scales.
| .withRules(['target-size']) | ||
| .analyze(); | ||
| const windowsScanned = scannedHtml(windowsResults); | ||
| expect( |
There was a problem hiding this comment.
Nit: this scan now asserts that both inputs are scanned and clean with the simulated windows class, but the PR body says this @server_only test wasn't run. The state differs from the real Windows test (text typed, clear buttons visible and overlapping the inputs), so it's worth one Server-mode run before merging.
There was a problem hiding this comment.
Not run on Server locally (this machine is Windows). The PR's e2e workflow has a Linux Server job, so I'll wait for that before merging. Meanwhile, a scratch copy of this test with AxeBuilder in legacy mode passed on Windows Desktop. That covers the windows-class scan with text typed and clear buttons showing, but with Windows fonts, not Linux ones.
| { | ||
| private boolean hasHooks_ = false; | ||
|
|
||
| SearchSuggestionDisplay() |
There was a problem hiding this comment.
Nit: the class is added only in SearchSuggestionDisplay, which is used when the caller passes a null display. The padding applies to every .search .searchBox, so a SearchWidget built with its own SuggestionDisplay would get the padded input without the popup offset (3px gap on Windows). No caller passes one today, so this is latent. The class comment above ("exists entirely so that we can inject some event handlers") is also no longer accurate.
There was a problem hiding this comment.
Comment updated in 2db0c81. No caller passes its own SuggestionDisplay today, so I've left the latent case alone rather than add code for it.
| } | ||
| /* Suggestions open at the input's bottom edge, which the padding moved 2px lower: | ||
| take 2px off the 3px offset .gwt-SuggestBoxPopup has (ThemedPopupPanel.css) */ | ||
| body.windows .searchSuggestPopup { |
There was a problem hiding this comment.
Nit: this assumes the list opens below the box. PopupPanel.showRelativeTo flips the popup above when there's no room below, and there the input's top edge didn't move, so on Windows a flipped list now sits 2px higher than before (overlapping the box by 1px instead of 3px). Harmless, but the comment only describes the below case.
There was a problem hiding this comment.
Comment updated in 2db0c81: it now says a list that flips above the box sits 2px higher.
Move the suggestion popup test and its sandbox into a nested describe, so the Server-only tests in the file no longer run the sandbox setup. Accept a popup gap between 0 and 2px, which still fails the old 3px, instead of 1px within 0.5px. Add Help's Find in Topic, a FindTextBox, to the Windows spacing test. Addresses #19786.
Say what SearchSuggestionDisplay is for now that it also gives the popup its Windows class, and note in themeStyles.css that a list flipped above the box sits 2px higher. Addresses #19786.
axe only fails a search input when a button happens to sit above it, which in the default layout Find in Topic doesn't have. Also require each input's center to be at least 12px below its toolbar's top edge; without the padding it is 11.5px. Check Find in Topic after activating Help, which may share a tabset with Environment. Addresses #19786.
RStudio E2E - all platformsAll tests passed!
All platforms - commit |
Fixes #19786.
The last item on #19786 (comment): on Windows,
body.windows .search { transform: translateY(-1px); }(#19163) lifts search boxes 1px. That puts each search input's center 11.5px below the toolbar row above, not the 12.5px it had before. Where a button sits directly above, axe-core'starget-sizerule reports 23px of clear space instead of 24px. In RStudio Desktop on Windows, the default layout gives Environment's search box (under the List/Grid view menu) this result at 100%, 125%, 150% and 200% scaling. Find in Topic has the same geometry and fails when the Help pane's layout puts a button above it.Changes
padding-bottom: 2px. Inputs are 17px tall instead of 15px, with their centers 12.5px below the toolbar's top edge again. The visual 1px lift stays, and the text doesn't move. This coversSearchWidgetboxes andFindTextBoxboxes (Find in Topic, the editor's Find/Replace bar).SuggestBoxopens suggestions at the input's bottom edge, which the padding moved 2px lower. Search widgets' suggestion popups now have asearchSuggestPopupclass. On Windows it sets a 1px top margin in place of the 3px all suggestion popups have, so Go to file/function and Help search suggestions still open 1px below the box. Other suggestion popups are unchanged.Tests
In
e2e/rstudio/tests/toolbar/toolbar_target_size.test.ts:@windows_onlytest: runs axe'starget-sizerule (in AxeBuilder's legacy mode, which Desktop supports) on the Environment, main toolbar and Find in Topic search inputs. It also checks that each input still spans its box after its first focus, and that its center is at least 12px below its toolbar's top edge, which catches the regression wherever the buttons above sit. It fails onmainwith the 23px result.@windows_onlytest: opens a file with a known function, types its name into Go to file/function, and expects the suggestion popup between 0 and 2px below the box (1px in practice). It fails at 3.3px with the old popup margin.windowsclass added tobody) now includes the inputs as well as the clear buttons. This one is@server_onlyand was not run locally.The two Windows tests pass on Windows Desktop at 100%, 125%, 150%, 175% and 200% scaling. With the padding and popup margin removed in the page, screenshots of all four toolbar search boxes and of the open suggestion list match the shipped ones pixel for pixel.