Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/web/src/viewmodels/structures/ResizerViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}%`);
}
};

Expand Down
35 changes: 25 additions & 10 deletions apps/web/test/viewmodels/structures/ResizerViewModel-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
Loading