From 818e8292cbef846ce3e97782ff10886d76aa7de7 Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Thu, 6 Apr 2023 16:02:18 +0200 Subject: [PATCH] Fix send two join requests when joining a room from spotlight search (#10534) * Fix send two join requests when joining a room from spotlight search * Trigger CI --------- Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/dialogs/spotlight/SpotlightDialog.tsx | 4 +++- test/components/views/dialogs/SpotlightDialog-test.tsx | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/views/dialogs/spotlight/SpotlightDialog.tsx b/src/components/views/dialogs/spotlight/SpotlightDialog.tsx index 6d64af4650..8a2f00496b 100644 --- a/src/components/views/dialogs/spotlight/SpotlightDialog.tsx +++ b/src/components/views/dialogs/spotlight/SpotlightDialog.tsx @@ -1,5 +1,5 @@ /* -Copyright 2021-2022 The Matrix.org Foundation C.I.C. +Copyright 2021 - 2023 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -624,6 +624,8 @@ const SpotlightDialog: React.FC = ({ initialText = "", initialFilter = n clientRoom?.getMyMembership() === "join" || result.publicRoom.world_readable || cli.isGuest(); const listener = (ev: ButtonEvent): void => { + ev.stopPropagation(); + const { publicRoom } = result; viewRoom( { diff --git a/test/components/views/dialogs/SpotlightDialog-test.tsx b/test/components/views/dialogs/SpotlightDialog-test.tsx index 2cc95324ff..e587ffbe5c 100644 --- a/test/components/views/dialogs/SpotlightDialog-test.tsx +++ b/test/components/views/dialogs/SpotlightDialog-test.tsx @@ -1,5 +1,5 @@ /* -Copyright 2022 The Matrix.org Foundation C.I.C. +Copyright 2022 - 2023 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -376,7 +376,8 @@ describe("Spotlight Dialog", () => { expect(options.length).toBe(1); expect(options[0].innerHTML).toContain(testPublicRoom.name); - fireEvent.click(options[0]!); + fireEvent.click(options[0].querySelector("[role='button']")!); + expect(defaultDispatcher.dispatch).toHaveBeenCalledTimes(1); expect(defaultDispatcher.dispatch).toHaveBeenCalledWith( expect.objectContaining({ action: "view_room",