fix: Fixed issue where Super note would convert whole line into tag even after closing menu
This commit is contained in:
@@ -36,8 +36,6 @@ export default function BlockPickerMenuPlugin(): JSX.Element {
|
|||||||
minLength: 0,
|
minLength: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
const [popoverOpen, setPopoverOpen] = useState(true)
|
|
||||||
|
|
||||||
const options = useMemo(() => {
|
const options = useMemo(() => {
|
||||||
const indentOutdentOptions = application.isNativeMobileWeb() ? GetIndentOutdentBlocks(editor) : []
|
const indentOutdentOptions = application.isNativeMobileWeb() ? GetIndentOutdentBlocks(editor) : []
|
||||||
|
|
||||||
@@ -90,7 +88,6 @@ export default function BlockPickerMenuPlugin(): JSX.Element {
|
|||||||
nodeToRemove.remove()
|
nodeToRemove.remove()
|
||||||
}
|
}
|
||||||
selectedOption.onSelect(matchingString)
|
selectedOption.onSelect(matchingString)
|
||||||
setPopoverOpen(false)
|
|
||||||
closeMenu()
|
closeMenu()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -105,12 +102,6 @@ export default function BlockPickerMenuPlugin(): JSX.Element {
|
|||||||
onSelectOption={onSelectOption}
|
onSelectOption={onSelectOption}
|
||||||
triggerFn={checkForTriggerMatch}
|
triggerFn={checkForTriggerMatch}
|
||||||
options={options}
|
options={options}
|
||||||
onClose={() => {
|
|
||||||
setPopoverOpen(false)
|
|
||||||
}}
|
|
||||||
onOpen={() => {
|
|
||||||
setPopoverOpen(true)
|
|
||||||
}}
|
|
||||||
menuRenderFn={(anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => {
|
menuRenderFn={(anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => {
|
||||||
if (!anchorElementRef.current || !options.length) {
|
if (!anchorElementRef.current || !options.length) {
|
||||||
return null
|
return null
|
||||||
@@ -120,10 +111,7 @@ export default function BlockPickerMenuPlugin(): JSX.Element {
|
|||||||
<Popover
|
<Popover
|
||||||
align="start"
|
align="start"
|
||||||
anchorElement={anchorElementRef.current}
|
anchorElement={anchorElementRef.current}
|
||||||
open={popoverOpen}
|
open={true}
|
||||||
togglePopover={() => {
|
|
||||||
setPopoverOpen((prevValue) => !prevValue)
|
|
||||||
}}
|
|
||||||
disableMobileFullscreenTakeover={true}
|
disableMobileFullscreenTakeover={true}
|
||||||
side={isMobileScreen() ? 'top' : 'bottom'}
|
side={isMobileScreen() ? 'top' : 'bottom'}
|
||||||
maxHeight={(mh) => mh / 2}
|
maxHeight={(mh) => mh / 2}
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ export const ItemSelectionPlugin: FunctionComponent<Props> = ({ currentNote }) =
|
|||||||
minLength: 0,
|
minLength: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
const [popoverOpen, setPopoverOpen] = useState(true)
|
|
||||||
|
|
||||||
const onSelectOption = useCallback(
|
const onSelectOption = useCallback(
|
||||||
(selectedOption: ItemOption, nodeToRemove: TextNode | null, closeMenu: () => void, matchingString: string) => {
|
(selectedOption: ItemOption, nodeToRemove: TextNode | null, closeMenu: () => void, matchingString: string) => {
|
||||||
editor.update(() => {
|
editor.update(() => {
|
||||||
@@ -40,7 +38,6 @@ export const ItemSelectionPlugin: FunctionComponent<Props> = ({ currentNote }) =
|
|||||||
nodeToRemove.remove()
|
nodeToRemove.remove()
|
||||||
}
|
}
|
||||||
selectedOption.options.onSelect(matchingString)
|
selectedOption.options.onSelect(matchingString)
|
||||||
setPopoverOpen(false)
|
|
||||||
closeMenu()
|
closeMenu()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -92,12 +89,6 @@ export const ItemSelectionPlugin: FunctionComponent<Props> = ({ currentNote }) =
|
|||||||
onSelectOption={onSelectOption}
|
onSelectOption={onSelectOption}
|
||||||
triggerFn={checkForTriggerMatch}
|
triggerFn={checkForTriggerMatch}
|
||||||
options={options}
|
options={options}
|
||||||
onClose={() => {
|
|
||||||
setPopoverOpen(false)
|
|
||||||
}}
|
|
||||||
onOpen={() => {
|
|
||||||
setPopoverOpen(true)
|
|
||||||
}}
|
|
||||||
menuRenderFn={(anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => {
|
menuRenderFn={(anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => {
|
||||||
if (!anchorElementRef.current || !options.length) {
|
if (!anchorElementRef.current || !options.length) {
|
||||||
return null
|
return null
|
||||||
@@ -107,10 +98,7 @@ export const ItemSelectionPlugin: FunctionComponent<Props> = ({ currentNote }) =
|
|||||||
<Popover
|
<Popover
|
||||||
align="start"
|
align="start"
|
||||||
anchorElement={anchorElementRef.current}
|
anchorElement={anchorElementRef.current}
|
||||||
open={popoverOpen}
|
open={true}
|
||||||
togglePopover={() => {
|
|
||||||
setPopoverOpen((prevValue) => !prevValue)
|
|
||||||
}}
|
|
||||||
disableMobileFullscreenTakeover={true}
|
disableMobileFullscreenTakeover={true}
|
||||||
side={isMobileScreen() ? 'top' : 'bottom'}
|
side={isMobileScreen() ? 'top' : 'bottom'}
|
||||||
maxHeight={(mh) => mh / 2}
|
maxHeight={(mh) => mh / 2}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ const Popover = ({
|
|||||||
|
|
||||||
if (open) {
|
if (open) {
|
||||||
removeListener = addAndroidBackHandler(() => {
|
removeListener = addAndroidBackHandler(() => {
|
||||||
togglePopover()
|
togglePopover?.()
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ const PositionedPopoverContent = ({
|
|||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
if (event.key === 'Escape') {
|
if (event.key === 'Escape') {
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
togglePopover()
|
togglePopover?.()
|
||||||
if (anchorElement) {
|
if (anchorElement) {
|
||||||
anchorElement.focus()
|
anchorElement.focus()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ type CommonPopoverProps = {
|
|||||||
children: ReactNode
|
children: ReactNode
|
||||||
side?: PopoverSide
|
side?: PopoverSide
|
||||||
overrideZIndex?: string
|
overrideZIndex?: string
|
||||||
togglePopover: () => void
|
togglePopover?: () => void
|
||||||
className?: string
|
className?: string
|
||||||
disableClickOutside?: boolean
|
disableClickOutside?: boolean
|
||||||
disableMobileFullscreenTakeover?: boolean
|
disableMobileFullscreenTakeover?: boolean
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useEffect } from 'react'
|
|||||||
type Options = {
|
type Options = {
|
||||||
popoverElement: HTMLElement | null
|
popoverElement: HTMLElement | null
|
||||||
anchorElement: HTMLElement | null | undefined
|
anchorElement: HTMLElement | null | undefined
|
||||||
togglePopover: () => void
|
togglePopover?: () => void
|
||||||
childPopovers: Set<string>
|
childPopovers: Set<string>
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ export const usePopoverCloseOnClickOutside = ({
|
|||||||
|
|
||||||
if (!isDescendantOfMenu && !isAnchorElement && !isDescendantOfChildPopover && !isDescendantOfChallengeModal) {
|
if (!isDescendantOfMenu && !isAnchorElement && !isDescendantOfChildPopover && !isDescendantOfChallengeModal) {
|
||||||
if (!disabled) {
|
if (!disabled) {
|
||||||
togglePopover()
|
togglePopover?.()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user