Skip to content

Commit

Permalink
Prevent tab focus on mousedown (#4239)
Browse files Browse the repository at this point in the history
Co-authored-by: Simone Todaro <simone.todaro@getchip.uk>
  • Loading branch information
SimoTod and SimoTod committed May 28, 2024
1 parent 2ddfff2 commit 1927cb1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/ui/src/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ function handleTab(el, Alpine) {
'@keydown.up.prevent.stop'() { this.$focus.within(this.$data.__activeTabs()).withWrapAround().prev() },
'@keydown.left.prevent.stop'() { this.$focus.within(this.$data.__activeTabs()).withWrapAround().prev() },
':tabindex'() { return this.$tab.isSelected ? 0 : -1 },
// This is important because we want to only focus the tab when it gets focus
// OR it finished the click event (mouseup). However, if you perform a `click`,
// then you will first get the `focus` and then get the `click` event.
// See https://github.com/tailwindlabs/headlessui/pull/1192
'@mousedown'(event) { event.preventDefault() },
'@focus'() {
if (this.$data.__manualActivation) {
this.$el.focus()
Expand Down

0 comments on commit 1927cb1

Please sign in to comment.