Skip to content

Commit a141791

Browse files
authored
Use prevent default and stop propagation (workadventure#4078)
When user clicks on the close button of the map editor, a pointer event is detected on the canvas behind and force to create area preview. The map editor is closed, but one area preview keeps visible. To fix this issue, we force to stop the event when user clicks on close button.
1 parent b33fb75 commit a141791

File tree

10 files changed

+21
-11
lines changed

10 files changed

+21
-11
lines changed

play/src/front/Components/ActionsMenu/ActionsMenu.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@
5151
{#if actionsMenuData}
5252
<div class="tw-flex tw-w-full tw-h-full tw-justify-center tw-items-center">
5353
<div class="actions-menu tw-p-4 is-rounded tw-max-w-xs">
54-
<button type="button" class="close-window" on:click={closeActionsMenu}>×</button>
54+
<button type="button" class="close-window" on:click|preventDefault|stopPropagation={closeActionsMenu}
55+
>×</button
56+
>
5557
{#if actionsMenuData.menuName}
5658
<h2 class="name tw-mb-2 !tw-mt-0 tw-mx-2 margin-close">{actionsMenuData.menuName}</h2>
5759
{/if}

play/src/front/Components/Chat/Chat.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
<div id="chatWindow" class:show={$chatVisibilityStore}>
244244
<input type="text" bind:this={searchElement} on:keydown={search} style="display: none;" />
245245
{#if $chatVisibilityStore}<div class="hide">
246-
<button class="close-window" on:click={closeChat}>&#215;</button>
246+
<button class="close-window" on:click|preventDefault|stopPropagation={closeChat}>&#215;</button>
247247
</div>{/if}
248248
<iframe
249249
id="chatWorkAdventure"

play/src/front/Components/EmbedScreens/Layouts/PresentationLayout.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
<button
9292
type="button"
9393
class="close-window top-right-btn"
94-
on:click={closeCoWebsite}
94+
on:click|preventDefault|stopPropagation={closeCoWebsite}
9595
>
9696
&times;
9797
</button>

play/src/front/Components/MapEditor/MapEditor.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@
3535
<button class="tw-absolute tw-right-10 tw-p-1 tw-cursor-pointer" on:click={hideMapEditor}
3636
><MinusIcon size="20" /></button
3737
>
38-
<button class="close-window" data-testid="mapEditor-close-button" on:click={closeMapEditor}>&#215;</button>
38+
<button
39+
class="close-window"
40+
data-testid="mapEditor-close-button"
41+
on:click|preventDefault|stopPropagation={closeMapEditor}>&#215;</button
42+
>
3943
{#if $mapEditorSelectedToolStore === EditorToolName.TrashEditor}
4044
<TrashEditor />
4145
{/if}

play/src/front/Components/MapEditor/PropertyEditor/JitsiRoomConfigEditor.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969

7070
<div class="menu-container center">
7171
<div class="tw-w-full tw-bg-dark-purple/95 tw-rounded" transition:fly={{ x: 1000, duration: 500 }}>
72-
<button type="button" class="close-window" on:click={close}>&times</button>
72+
<button type="button" class="close-window" on:click|preventDefault|stopPropagation={close}>&times</button>
7373
<select class="tag-selector" bind:value={selectedKey} on:change={() => onSelectedKey()}>
7474
<option value="">{$LL.mapEditor.properties.jitsiProperties.jitsiRoomConfig.addConfig()}</option>
7575
{#each defaultConfigKeys as configKey (configKey)}

play/src/front/Components/MapEditor/WAMSettingsEditor.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</script>
3434

3535
<div class="configure-my-room" in:fly={{ x: 100, duration: 250, delay: 200 }} out:fly={{ x: 100, duration: 200 }}>
36-
<button class="close-window" on:click={close}>&#215;</button>
36+
<button class="close-window" on:click|preventDefault|stopPropagation={close}>&#215;</button>
3737
<div class="menu">
3838
<h3>{$LL.mapEditor.sideBar.configureMyRoom()}</h3>
3939
<ul>

play/src/front/Components/Menu/Menu.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,10 @@
129129
<h2 class="tw-p-5 blue-title">{$LL.menu.title()}</h2>
130130
<nav>
131131
{#each $subMenusStore as submenu, i (submenu.key + "_" + submenu.type)}
132+
<!-- svelte-ignore a11y-click-events-have-key-events -->
132133
<div
133134
class="menu-item-container {activeSubMenu === submenu ? 'active' : ''}"
134-
on:click|preventDefault={() => switchMenu(submenu)}
135+
on:click|preventDefault|stopPropagation={() => switchMenu(submenu)}
135136
>
136137
<button type="button" class="tw-flex menu-item">
137138
{subMenuTranslations[i]}
@@ -142,7 +143,7 @@
142143
</nav>
143144
</div>
144145
<div class="menu-submenu-container tw-bg-dark-purple/95 tw-rounded" transition:fly={{ y: -1000, duration: 500 }}>
145-
<button type="button" class="close-window" on:click={closeMenu}>&times;</button>
146+
<button type="button" class="close-window" on:click|preventDefault|stopPropagation={closeMenu}>&times;</button>
146147
<h2>{activeSubMenuTranslation}</h2>
147148
<svelte:component this={activeComponent} {...props} />
148149
</div>

play/src/front/Components/Modal/GlobalCommunicationModal.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165

166166
<div class="menu-container {isMobile ? 'mobile' : 'center'} tw-h-3/4" bind:this={mainModal}>
167167
<div class="tw-w-full tw-bg-dark-purple/95 tw-rounded" transition:fly={{ x: 1000, duration: 500 }}>
168-
<button type="button" class="close-window" on:click={close}>&times</button>
168+
<button type="button" class="close-window" on:click|preventDefault|stopPropagation={close}>&times</button>
169169
<header>
170170
<h2 class="tw-p-5 blue-title">Global communication</h2>
171171
{#if activeLiveMessage || inputSendTextActive || uploadAudioActive}

play/src/front/Components/Modal/Modal.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
<div class="menu-container {isMobile ? 'mobile' : $modalIframeStore?.position}" bind:this={mainModal}>
5151
<div class="tw-w-full tw-bg-dark-purple/95 tw-rounded" transition:fly={{ x: 1000, duration: 500 }}>
52-
<button type="button" class="close-window" on:click={close}>&times</button>
52+
<button type="button" class="close-window" on:click|preventDefault|stopPropagation={close}>&times</button>
5353
{#if modalUrl != undefined}
5454
<iframe
5555
id="modalIframe"

play/src/front/Components/Modal/Popup.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88

99
{#if isOpen}
1010
<div class="popup-menu tw-min-h-fit tw-rounded-3xl tw-overflow-visible" transition:fly={{ x: 1000, duration: 500 }}>
11-
<button type="button" class="close-window !tw-bg-transparent !tw-border-none " on:click={closeModal}
11+
<button
12+
type="button"
13+
class="close-window !tw-bg-transparent !tw-border-none "
14+
on:click|preventDefault|stopPropagation={closeModal}
1215
>&times
1316
</button>
1417
<div class="tw-p-8 tw-flex tw-flex-col tw-justify-center tw-items-center">

0 commit comments

Comments
 (0)