disable ListBox space shotcut

This commit is contained in:
Sanster 2022-02-06 21:32:54 +08:00
parent df53f81032
commit b4dc7a0253
2 changed files with 10 additions and 2 deletions

View File

@ -439,6 +439,7 @@ export default function Editor(props: EditorProps) {
' ', ' ',
ev => { ev => {
ev?.preventDefault() ev?.preventDefault()
ev?.stopPropagation()
setShowBrush(!showBrush) setShowBrush(!showBrush)
setIsPanning(!isPanning) setIsPanning(!isPanning)
}, },

View File

@ -1,4 +1,4 @@
import React from 'react' import React, { FocusEvent } from 'react'
import { Listbox } from '@headlessui/react' import { Listbox } from '@headlessui/react'
import { CheckIcon, SelectorIcon } from '@heroicons/react/solid' import { CheckIcon, SelectorIcon } from '@heroicons/react/solid'
@ -31,6 +31,10 @@ export default function SizeSelector(props: SizeSelectorProps) {
return `${newWidth}x${size}` return `${newWidth}x${size}`
} }
const onButtonFocus = (e: FocusEvent<any>) => {
e.currentTarget.blur()
}
return ( return (
<div className="w-52"> <div className="w-52">
<Listbox value={value} onChange={onChange}> <Listbox value={value} onChange={onChange}>
@ -72,7 +76,10 @@ export default function SizeSelector(props: SizeSelectorProps) {
</Listbox.Option> </Listbox.Option>
))} ))}
</Listbox.Options> </Listbox.Options>
<Listbox.Button className="relative w-full inline-flex w-full px-4 py-2 text-sm font-medium bg-black rounded-md bg-opacity-10 focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75"> <Listbox.Button
onFocus={onButtonFocus}
className="relative w-full inline-flex w-full px-4 py-2 text-sm font-medium bg-black rounded-md bg-opacity-10 focus:outline-none "
>
<span className="block truncate">{getSizeShowName(value)}</span> <span className="block truncate">{getSizeShowName(value)}</span>
<span className="absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"> <span className="absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none">
<SelectorIcon <SelectorIcon