Skip to content

Commit b8b302e

Browse files
authored
fix(context-menu): avoid reposition when sub are open and update story items (#10154)
1 parent 9f27dd7 commit b8b302e

File tree

2 files changed

+25
-52
lines changed

2 files changed

+25
-52
lines changed

packages/ui/src/lib/components/ContextMenu.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,9 @@
343343
const observer = new MutationObserver((mutationList) => {
344344
for (const mutation of mutationList) {
345345
if (mutation.type === 'childList') {
346-
if (isVisible && savedMouseEvent) {
346+
// Only reposition if we don't have open submenus
347+
// This prevents the menu from jumping when submenus open
348+
if (isVisible && savedMouseEvent && !submenuCoordination.hasOpenSubmenus()) {
347349
setPosition(savedMouseEvent);
348350
}
349351
}

packages/ui/src/stories/components/ContextMenu.stories.svelte

Lines changed: 22 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,28 @@
171171
contextMenu?.close();
172172
}}
173173
/>
174+
<ContextMenuItemSubmenu label="More actions">
175+
{#snippet submenu({ close })}
176+
<ContextMenuSection>
177+
<ContextMenuItem
178+
label="Cherry-pick"
179+
onclick={() => {
180+
console.log('Cherry-pick');
181+
close();
182+
contextMenu?.close();
183+
}}
184+
/>
185+
<ContextMenuItem
186+
label="Rebase"
187+
onclick={() => {
188+
console.log('Rebase');
189+
close();
190+
contextMenu?.close();
191+
}}
192+
/>
193+
</ContextMenuSection>
194+
{/snippet}
195+
</ContextMenuItemSubmenu>
174196
</ContextMenuSection>
175197
<ContextMenuSection title="Branch operations">
176198
<ContextMenuItem
@@ -187,27 +209,6 @@
187209
contextMenu?.close();
188210
}}
189211
/>
190-
<ContextMenuItem
191-
label="Delete branch"
192-
onclick={() => {
193-
console.log('Delete branch');
194-
contextMenu?.close();
195-
}}
196-
/>
197-
<ContextMenuItem
198-
label="Rename branch"
199-
onclick={() => {
200-
console.log('Rename branch');
201-
contextMenu?.close();
202-
}}
203-
/>
204-
<ContextMenuItem
205-
label="Compare branches"
206-
onclick={() => {
207-
console.log('Compare branches');
208-
contextMenu?.close();
209-
}}
210-
/>
211212
</ContextMenuSection>
212213
<ContextMenuSection>
213214
<ContextMenuItem
@@ -255,36 +256,6 @@
255256
}}
256257
/>
257258
</ContextMenuSection>
258-
<ContextMenuSection>
259-
<ContextMenuItem
260-
label="Clone"
261-
onclick={() => {
262-
console.log('Clone');
263-
contextMenu?.close();
264-
}}
265-
/>
266-
<ContextMenuItem
267-
label="Fork"
268-
onclick={() => {
269-
console.log('Fork');
270-
contextMenu?.close();
271-
}}
272-
/>
273-
<ContextMenuItem
274-
label="Archive"
275-
onclick={() => {
276-
console.log('Archive');
277-
contextMenu?.close();
278-
}}
279-
/>
280-
<ContextMenuItem
281-
label="Settings"
282-
onclick={() => {
283-
console.log('Settings');
284-
contextMenu?.close();
285-
}}
286-
/>
287-
</ContextMenuSection>
288259
</ContextMenu>
289260
{/snippet}
290261
</Story>

0 commit comments

Comments
 (0)