Collapsible Left Panel - Clicking on separator should expand to 100% when no width is available in settings (#33053)

* Expand panel to full width

* Write tests
This commit is contained in:
R Midhun Suresh
2026-04-07 12:05:36 +00:00
committed by GitHub
parent f12b23a87a
commit 6b00466a85
2 changed files with 26 additions and 11 deletions
@@ -76,7 +76,7 @@ export class ResizerViewModel
public onSeparatorClick = (): void => { public onSeparatorClick = (): void => {
if (this.panelHandle?.isCollapsed()) { if (this.panelHandle?.isCollapsed()) {
const lastSize = SettingsStore.getValue("RoomList.panelSize"); const lastSize = SettingsStore.getValue("RoomList.panelSize");
this.panelHandle.resize(`${lastSize}%`); this.panelHandle.resize(`${lastSize ?? 100}%`);
} }
}; };
@@ -68,18 +68,33 @@ describe("LeftPanelResizerViewModel", () => {
expect(() => vm.onSeparatorClick()).not.toThrow(); expect(() => vm.onSeparatorClick()).not.toThrow();
}); });
it("should expand panel on onSeparatorClick()", () => { describe("should expand panel on onSeparatorClick()", () => {
const vm = new ResizerViewModel(); it("to last non-zero width that the user set", () => {
SettingsStore.setValue("RoomList.panelSize", null, SettingLevel.DEVICE, 34); const vm = new ResizerViewModel();
const mockHandle = { SettingsStore.setValue("RoomList.panelSize", null, SettingLevel.DEVICE, 34);
resize: jest.fn(), const mockHandle = {
isCollapsed: jest.fn().mockReturnValue(true), resize: jest.fn(),
} as unknown as PanelImperativeHandle; isCollapsed: jest.fn().mockReturnValue(true),
vm.setPanelHandle(mockHandle); } as unknown as PanelImperativeHandle;
vm.setPanelHandle(mockHandle);
vm.onSeparatorClick(); vm.onSeparatorClick();
expect(mockHandle.resize).toHaveBeenCalledWith("34%"); expect(mockHandle.resize).toHaveBeenCalledWith("34%");
});
it("to maximum size of the panel", () => {
const vm = new ResizerViewModel();
const mockHandle = {
resize: jest.fn(),
isCollapsed: jest.fn().mockReturnValue(true),
} as unknown as PanelImperativeHandle;
vm.setPanelHandle(mockHandle);
vm.onSeparatorClick();
expect(mockHandle.resize).toHaveBeenCalledWith("100%");
});
}); });
it("should set isFocusedViaKeyboard state correctly", () => { it("should set isFocusedViaKeyboard state correctly", () => {