Skip to content

Commit

Permalink
fix(ld-context-menu): do not open on right click if not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
borisdiakur committed Jun 12, 2023
1 parent e71b8d1 commit e21b46c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,33 @@ describe('ld-context-menu', () => {
expect(firstMenuItemInTooltip.focusInner).toHaveBeenCalled()
})

it('does not open on right-click if right-click is not enabled', async () => {
const page = await newSpecPage({
components: [LdContextMenu, LdMenuitem, LdTooltip, LdMenu, LdButton],
template: () => (
<ld-context-menu>
<ld-button slot="trigger">Open</ld-button>
<ld-menuitem>Menu item</ld-menuitem>
</ld-context-menu>
),
})
const tooltip = page.root.shadowRoot.querySelector('ld-tooltip')
const menu = page.root.shadowRoot.querySelector('ld-menu')
const triggerButton = page.root.querySelector('ld-button')

const menuInTooltip = await prepareAndGetMenuInTooltip(
page,
[triggerButton],
[menu]
)
const firstMenuItemInTooltip = menuInTooltip.querySelector('ld-menuitem')

tooltip.handleContextMenu(new Event('contextMenu'))
await page.waitForChanges()

expect(firstMenuItemInTooltip.focusInner).not.toHaveBeenCalled()
})

it('closes on right-click of other context menu', async () => {
const page = await newSpecPage({
components: [LdContextMenu, LdMenuitem, LdTooltip, LdMenu, LdButton],
Expand Down
2 changes: 1 addition & 1 deletion src/liquid/components/ld-tooltip/ld-tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export class LdTooltip {
/** @internal */
@Method()
async handleContextMenu(ev) {
if (this.disabled) return
if (!this.rightClick || this.disabled) return

ev.preventDefault()
this.toggleTooltip()
Expand Down

1 comment on commit e21b46c

@vercel
Copy link

@vercel vercel bot commented on e21b46c Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

liquid – ./

liquid-oxygen.vercel.app
liquid-git-main-uxsd.vercel.app
liquid-uxsd.vercel.app

Please sign in to comment.