Skip to content

Commit

Permalink
fix(menu): menu link items not clicking on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Nov 8, 2023
1 parent 0515d97 commit 8e2b430
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/dull-berries-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zag-js/menu": patch
---

Fix issue issue where link is not clickable on mobile
5 changes: 0 additions & 5 deletions packages/machines/combobox/src/combobox.connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,6 @@ export function connect<T extends PropTypes, V extends CollectionItem>(
if (itemState.isDisabled || isContextMenuEvent(event)) return
send({ type: "ITEM.CLICK", src: "pointerup", value })
},
onAuxClick(event) {
if (itemState.isDisabled || isContextMenuEvent(event)) return
event.preventDefault()
send({ type: "ITEM.CLICK", src: "auxclick", value })
},
})
},

Expand Down
17 changes: 4 additions & 13 deletions packages/machines/menu/src/menu.connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,10 @@ export function connect<T extends PropTypes>(state: State, send: Send, normalize
if (!isLeftClick(evt) || itemState.isDisabled) return
const target = event.currentTarget
send({ type: "ITEM_CLICK", src: "pointerup", target, id, closeOnSelect })
},
onAuxClick(event) {
if (itemState.isDisabled) return
event.preventDefault()
const target = event.currentTarget
send({ type: "ITEM_CLICK", src: "auxclick", target, id, closeOnSelect })
// Fix issue where links don't get clicked in pointerup on touch devices
if (target.matches("a[href]") && event.pointerType === "touch") {
target.click()
}
},
})
}
Expand Down Expand Up @@ -375,13 +373,6 @@ export function connect<T extends PropTypes>(state: State, send: Send, normalize
send({ type: "ITEM_CLICK", src: "pointerup", target, option, closeOnSelect })
onCheckedChange?.(!itemState.isChecked)
},
onAuxClick(event) {
if (disabled) return
event.preventDefault()
const target = event.currentTarget
send({ type: "ITEM_CLICK", src: "auxclick", target, option, closeOnSelect })
onCheckedChange?.(!itemState.isChecked)
},
}),
)
},
Expand Down

4 comments on commit 8e2b430

@vercel
Copy link

@vercel vercel bot commented on 8e2b430 Nov 8, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 8e2b430 Nov 8, 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:

zag-nextjs – ./examples/next-ts

zag-two.vercel.app
zag-nextjs-chakra-ui.vercel.app
zag-nextjs-git-main-chakra-ui.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 8e2b430 Nov 8, 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:

zag-solid – ./examples/solid-ts

zag-solid.vercel.app
zag-solid-git-main-chakra-ui.vercel.app
zag-solid-chakra-ui.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 8e2b430 Nov 8, 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:

zag-vue – ./examples/vue-ts

zag-vue-git-main-chakra-ui.vercel.app
zag-vue-chakra-ui.vercel.app
zag-vue.vercel.app

Please sign in to comment.