Skip to content

Commit

Permalink
fix: focus issues on android
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara committed Aug 16, 2023
1 parent d6c4338 commit 83aafbf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { classNames } from '@standardnotes/snjs'
import { ReactNode, useState, useRef, useEffect, MouseEvent } from 'react'
import { ReactNode, useState, useRef, useEffect } from 'react'
import { Tooltip, TooltipAnchor, TooltipOptions, useTooltipStore } from '@ariakit/react'
import { Slot } from '@radix-ui/react-slot'
import { MutuallyExclusiveMediaQueryBreakpoints, useMediaQuery } from '@/Hooks/useMediaQuery'
Expand Down Expand Up @@ -57,6 +57,12 @@ const StyledTooltip = ({
}
}, [attachLongPressEvents, cleanupLongPressEvents, isMobile, showOnMobile])

const clickProps = isMobile
? {}
: {
onClick: () => setForceOpen(false),
}

if (isMobile && !showOnMobile) {
return <>{children}</>
}
Expand All @@ -65,12 +71,7 @@ const StyledTooltip = ({
<>
<TooltipAnchor
ref={anchorRef}
onClick={() => setForceOpen(false)}
onContextMenu={(event: MouseEvent) => {
if (isMobile && showOnMobile) {
event.preventDefault()
}
}}
{...clickProps}
onBlur={() => setForceOpen(undefined)}
store={tooltip}
as={Slot}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,14 @@ const MobileToolbarPlugin = () => {
<button
className="flex items-center justify-center rounded p-0.5 disabled:opacity-50 select-none hover:bg-default"
aria-label={item.name}
onClick={item.onSelect}
onMouseDown={(event) => {
event.preventDefault()
item.onSelect()
}}
onContextMenu={(event) => {
editor.focus()
event.preventDefault()
}}
disabled={item.disabled}
>
<div
Expand Down

0 comments on commit 83aafbf

Please sign in to comment.