Collapsible Left Panel - Ensure that panels have non-fractional widths (#33052)

* Expand panel to full width

* Write tests

* Resize to nearest whole number if necessary

* Update screenshots

* Early return when resizing to whole width

* Update screenshot
This commit is contained in:
R Midhun Suresh 2026-04-07 21:14:51 +05:30 committed by GitHub
parent 6c1dc7051f
commit edea3fffdf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 17 additions and 0 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 KiB

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 KiB

After

Width:  |  Height:  |  Size: 167 KiB

View File

@ -57,6 +57,12 @@ export class ResizerViewModel
}, 50);
public onLeftPanelResized = (newSize: number): void => {
// We don't want the panels to have fractional widths as that can cause blurry UI elements.
if (!Number.isInteger(newSize)) {
this.panelHandle?.resize(`${Math.round(newSize)}%`);
return;
}
const isCollapsed = newSize === 0;
// Store the size if the panel isn't collapsed.
if (!isCollapsed) {

View File

@ -105,4 +105,15 @@ describe("LeftPanelResizerViewModel", () => {
vm.onBlur();
expect(vm.getSnapshot().isFocusedViaKeyboard).toStrictEqual(false);
});
it("should resize to nearest whole number", () => {
const vm = new ResizerViewModel();
const mockHandle = {
resize: jest.fn(),
} as unknown as PanelImperativeHandle;
vm.setPanelHandle(mockHandle);
vm.onLeftPanelResized(25.515);
expect(mockHandle.resize).toHaveBeenCalledWith("26%");
});
});