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 17:35:36 +05:30 committed by GitHub
parent f12b23a87a
commit 6b00466a85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 11 deletions

View File

@ -76,7 +76,7 @@ export class ResizerViewModel
public onSeparatorClick = (): void => {
if (this.panelHandle?.isCollapsed()) {
const lastSize = SettingsStore.getValue("RoomList.panelSize");
this.panelHandle.resize(`${lastSize}%`);
this.panelHandle.resize(`${lastSize ?? 100}%`);
}
};

View File

@ -68,18 +68,33 @@ describe("LeftPanelResizerViewModel", () => {
expect(() => vm.onSeparatorClick()).not.toThrow();
});
it("should expand panel on onSeparatorClick()", () => {
const vm = new ResizerViewModel();
SettingsStore.setValue("RoomList.panelSize", null, SettingLevel.DEVICE, 34);
const mockHandle = {
resize: jest.fn(),
isCollapsed: jest.fn().mockReturnValue(true),
} as unknown as PanelImperativeHandle;
vm.setPanelHandle(mockHandle);
describe("should expand panel on onSeparatorClick()", () => {
it("to last non-zero width that the user set", () => {
const vm = new ResizerViewModel();
SettingsStore.setValue("RoomList.panelSize", null, SettingLevel.DEVICE, 34);
const mockHandle = {
resize: jest.fn(),
isCollapsed: jest.fn().mockReturnValue(true),
} 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", () => {