Room list: scroll to newly creation section (#33210)

* feat(rls): emit tag when section is created

* feat(vm): scroll to newly section tag

* feat(view): scroll to new section
This commit is contained in:
Florian Duros
2026-04-22 14:21:41 +02:00
committed by GitHub
parent 29411f0ded
commit 9df9fb9428
9 changed files with 101 additions and 27 deletions
@@ -1015,7 +1015,7 @@ describe("RoomListStoreV3", () => {
it("emits SECTION_CREATED_EVENT and LISTS_UPDATE_EVENT when section is created", async () => {
enableSections();
getClientAndRooms();
jest.spyOn(sectionModule, "createSection").mockResolvedValue(true);
jest.spyOn(sectionModule, "createSection").mockResolvedValue("element.io.section.test-tag");
const store = new RoomListStoreV3Class(dispatcher);
await store.start();
@@ -1027,14 +1027,13 @@ describe("RoomListStoreV3", () => {
await store.createSection();
expect(sectionCreatedListener).toHaveBeenCalled();
expect(listsUpdateListener).toHaveBeenCalled();
expect(sectionCreatedListener).toHaveBeenCalledWith("element.io.section.test-tag");
});
it("does not emit when section creation is cancelled", async () => {
enableSections();
getClientAndRooms();
jest.spyOn(sectionModule, "createSection").mockResolvedValue(false);
jest.spyOn(sectionModule, "createSection").mockResolvedValue(undefined);
const store = new RoomListStoreV3Class(dispatcher);
await store.start();
@@ -21,10 +21,9 @@ describe("createSection", () => {
});
it.each([
[false, "", false],
[true, "", false],
[true, "My Section", true],
])("returns %s when shouldCreate=%s and name='%s'", async (shouldCreate, name, expected) => {
[false, "", undefined],
[true, "", undefined],
])("returns undefined when shouldCreate=%s and name='%s'", async (shouldCreate, name, expected) => {
jest.spyOn(Modal, "createDialog").mockReturnValue({
finished: Promise.resolve([shouldCreate, name]),
close: jest.fn(),
@@ -34,6 +33,16 @@ describe("createSection", () => {
expect(result).toBe(expected);
});
it("returns the new tag when section is created", async () => {
jest.spyOn(Modal, "createDialog").mockReturnValue({
finished: Promise.resolve([true, "My Section"]),
close: jest.fn(),
} as any);
const result = await createSection();
expect(result).toMatch(/^element\.io\.section\./);
});
it("opens the CreateSectionDialog", async () => {
const createDialogSpy = jest.spyOn(Modal, "createDialog").mockReturnValue({
finished: Promise.resolve([false, ""]),