Repository navigation
Fit the source editor toolbar to its width by measuring - #19897
Merged
Merged
Conversation
The toolbar sheds width in the same order as before (go-to buttons, split buttons, render labels, publish caption, ...), but now steps through that order until its widgets no longer overflow, instead of at fixed widths that no longer matched what the toolbar holds. The Run menu's label now drops with the Run button's.
The publish button's caption (Publish to Republish) and visibility change as deployment records arrive, after the toolbar has fitted itself; it now tells the editor, which fits the toolbar again.
Replaces the test of #19786's fixed breakpoints with one that, at widths where those breakpoints left a control clipped, checks that no control is, and that widening restores the controls given up.
Activating a tab fits its toolbar as well, so a check right after one could pass even if resizing left the toolbar clipped.
A label or button that widens after the toolbar is fitted (a YAML edit restoring Render's label, Run App becoming Reload App, the publish button's menu half appearing) clipped controls until the next resize. The toolbar now runs the fit itself and watches its widgets with a ResizeObserver, refitting when they reach a width its last fit didn't leave. This replaces the publish button's own width callback.
Also retry a splitter drag that doesn't take, rather than fail the test, and allow the toolbar 2px from its target width.
The toolbar's observer can't see the toggle change while the fit has hidden it, so the editor split button stayed hidden when it would fit alone.
The toolbar's ResizeObserver replaced it in 4ea8d2c, which meant to remove it but kept it by mistake; nothing registers the callback.
Selecting a tab fits its toolbar in a deferred command, so the test's baseline could be read before the fit.
RStudio E2E - all platformsAll tests passed!
All platforms - commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #19896.
The source editor toolbar used to hide its buttons and labels at fixed pane widths. Those widths no longer matched what the toolbar holds, so at several widths it pushed its rightmost buttons past its right edge. Examples: "Toggle the second view of this document", "Show Changes Side by Side", and "Publish options" in a Quarto or R Markdown document, and "Show document outline" in an R script.
The toolbar now fits itself by measuring. On each layout it shows everything, then gives up width in the same order as before until its widgets no longer overflow. The order is: the go-to section buttons; the split editor and diff toggle buttons; the Render/Knit/Preview/Compile PDF labels; the publish caption; the Format label; the shorter "Render on Save" label; the Run labels; and the Source label. The Run menu's label on R Markdown and Quarto documents now drops in the same step as the Run button's.
ToolbargainsfitWidgets(lastStep, step -> ...), which runs that loop. It also gainsonWidgetsResized(command), which watches the toolbar's widgets with aResizeObserver. When a widget changes width after a fit, for example a YAML edit restoring Render's label, Run App becoming Reload App, or the publish button's caption becoming Republish, the toolbar fits again. The observer ignores the width a fit leaves, so a fit doesn't trigger itself.TextEditingTargetWidgetsupplies the steps and refits when the diff toggle becomes available or unavailable, which the observer can't see while the fit has hidden the toggle.showsMenuHalf()and its 20px allowance for split buttons' menu halves are removed. Measuring covers them.At the narrowest widths, below about 450px for a Quarto document, the toolbar still overflows: everything that can be hidden already is.
Testing
e2e/rstudio/tests/toolbar/source_toolbar_breakpoints.test.tsreplaces its test of Controls are smaller than the WCAG 2.2 minimum target size and too closely spaced #19786's fixed breakpoints with two tests, run withnpm run test:server-dev:mainand passes here.The go-to section buttons' visibility still comes from the global chunk commands, as before. That's tracked separately in #19895.