From ba11551dfa3bbc2ab4c05cbe6d9cb15adc7bfe95 Mon Sep 17 00:00:00 2001 From: Aman Harwara Date: Thu, 14 Dec 2023 23:28:24 +0530 Subject: [PATCH] Revert "refactor: use ariakit for super note popovers" This reverts commit 3c5c6723ac4dc018d07ba8b79537262d3a009be3. --- .../BlockPickerPlugin/BlockPickerMenuItem.tsx | 4 +- .../BlockPickerPlugin/BlockPickerPlugin.tsx | 86 +++++++++--------- .../SuperEditor/Plugins/ClassNames.ts | 6 +- .../ItemSelectionPlugin.tsx | 88 +++++++++---------- 4 files changed, 94 insertions(+), 90 deletions(-) diff --git a/packages/web/src/javascripts/Components/SuperEditor/Plugins/BlockPickerPlugin/BlockPickerMenuItem.tsx b/packages/web/src/javascripts/Components/SuperEditor/Plugins/BlockPickerPlugin/BlockPickerMenuItem.tsx index 2840a134a..51f002a3e 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Plugins/BlockPickerPlugin/BlockPickerMenuItem.tsx +++ b/packages/web/src/javascripts/Components/SuperEditor/Plugins/BlockPickerPlugin/BlockPickerMenuItem.tsx @@ -19,7 +19,9 @@ export function BlockPickerMenuItem({
  • {modal} - - - onQueryChange={setQueryString} - onSelectOption={onSelectOption} - triggerFn={checkForTriggerMatch} - options={options} - menuRenderFn={(anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => { - if (!anchorElementRef.current || !options.length) { - return null - } - return ( - anchorElementRef.current!.getBoundingClientRect()} - autoFocus={false} - autoFocusOnShow={false} - className={PopoverClassNames} - fitViewport - > -
      - {options.map((option, i: number) => ( - { - setHighlightedIndex(i) - selectOptionAndCleanUp(option) - }} - onMouseEnter={() => { - setHighlightedIndex(i) - }} - key={option.key} - option={option} - /> - ))} -
    -
    - ) - }} - /> -
    + + onQueryChange={setQueryString} + onSelectOption={onSelectOption} + triggerFn={checkForTriggerMatch} + options={options} + menuRenderFn={(anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => { + if (!anchorElementRef.current || !options.length) { + return null + } + + return ( + mh / 2} + > +
      + {options.map((option, i: number) => ( + { + setHighlightedIndex(i) + selectOptionAndCleanUp(option) + }} + onMouseEnter={() => { + setHighlightedIndex(i) + }} + key={option.key} + option={option} + /> + ))} +
    +
    + ) + }} + /> ) } diff --git a/packages/web/src/javascripts/Components/SuperEditor/Plugins/ClassNames.ts b/packages/web/src/javascripts/Components/SuperEditor/Plugins/ClassNames.ts index 60ed515b6..fb1f58a49 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Plugins/ClassNames.ts +++ b/packages/web/src/javascripts/Components/SuperEditor/Plugins/ClassNames.ts @@ -1,7 +1,9 @@ import { classNames } from '@standardnotes/utils' -export const PopoverClassNames = - 'max-h-[min(var(--popover-available-height,_50vh),_50vh)] w-[--popover-available-width] overflow-y-auto rounded border border-[--popover-border-color] bg-default shadow-main [backdrop-filter:var(--popover-backdrop-filter)] md:max-w-xs md:bg-[--popover-background-color]' +export const PopoverClassNames = classNames( + 'z-dropdown-menu w-full', + 'cursor-auto flex-col overflow-y-auto rounded bg-default h-auto', +) export const PopoverItemClassNames = classNames( 'flex w-full items-center text-base overflow-hidden py-2 px-3 hover:bg-contrast hover:text-foreground', diff --git a/packages/web/src/javascripts/Components/SuperEditor/Plugins/ItemSelectionPlugin/ItemSelectionPlugin.tsx b/packages/web/src/javascripts/Components/SuperEditor/Plugins/ItemSelectionPlugin/ItemSelectionPlugin.tsx index 377e17eef..6b8a9d015 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Plugins/ItemSelectionPlugin/ItemSelectionPlugin.tsx +++ b/packages/web/src/javascripts/Components/SuperEditor/Plugins/ItemSelectionPlugin/ItemSelectionPlugin.tsx @@ -7,11 +7,11 @@ import { ItemOption } from './ItemOption' import { useApplication } from '@/Components/ApplicationProvider' import { ContentType, SNNote } from '@standardnotes/snjs' import { getLinkingSearchResults } from '@/Utils/Items/Search/getSearchResults' +import Popover from '@/Components/Popover/Popover' import { INSERT_BUBBLE_COMMAND, INSERT_FILE_COMMAND } from '../Commands' import { useLinkingController } from '../../../../Controllers/LinkingControllerProvider' +import { isMobileScreen } from '@/Utils' import { useTypeaheadAllowingSpacesAndPunctuation } from './useTypeaheadAllowingSpacesAndPunctuation' -import { Popover, PopoverProvider } from '@ariakit/react' -import { PopoverClassNames } from '../ClassNames' type Props = { currentNote: SNNote @@ -83,47 +83,47 @@ export const ItemSelectionPlugin: FunctionComponent = ({ currentNote }) = }, [application, editor, currentNote, queryString, linkingController]) return ( - - - onQueryChange={setQueryString} - onSelectOption={onSelectOption} - triggerFn={checkForTriggerMatch} - options={options} - menuRenderFn={(anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => { - if (!anchorElementRef.current || !options.length) { - return null - } - return ( - anchorElementRef.current!.getBoundingClientRect()} - autoFocus={false} - autoFocusOnShow={false} - className={PopoverClassNames} - fitViewport - > -
      - {options.map((option, i: number) => ( - { - setHighlightedIndex(i) - selectOptionAndCleanUp(option) - }} - onMouseEnter={() => { - setHighlightedIndex(i) - }} - key={option.key} - option={option} - /> - ))} -
    -
    - ) - }} - /> -
    + + onQueryChange={setQueryString} + onSelectOption={onSelectOption} + triggerFn={checkForTriggerMatch} + options={options} + menuRenderFn={(anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => { + if (!anchorElementRef.current || !options.length) { + return null + } + + return ( + mh / 2} + > +
      + {options.map((option, i: number) => ( + { + setHighlightedIndex(i) + selectOptionAndCleanUp(option) + }} + onMouseEnter={() => { + setHighlightedIndex(i) + }} + key={option.key} + option={option} + /> + ))} +
    +
    + ) + }} + /> ) }