Skip to content

Commit

Permalink
Merge pull request #9770 from robojumper/autocomplete-dropdown-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bhollis authored Aug 26, 2023
2 parents dcd7760 + 2d29315 commit df57a66
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/app/dim-ui/destiny-symbols/SymbolsPicker.m.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
display: flex;
flex-flow: column;
box-shadow: var(--theme-drop-shadow);
pointer-events: auto;
}

.symbolsButton {
Expand Down
27 changes: 19 additions & 8 deletions src/app/dim-ui/destiny-symbols/SymbolsPicker.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import { t } from 'app/i18next-t';
import { SearchInput } from 'app/search/SearchInput';
import { Portal } from 'app/utils/temp-container';
import { tempContainer } from 'app/utils/temp-container';
import clsx from 'clsx';
import { FontGlyphs } from 'data/d2/d2-font-glyphs';
import React, { HTMLProps, memo, useCallback, useEffect, useRef, useState } from 'react';
import React, {
HTMLProps,
memo,
useCallback,
useContext,
useEffect,
useRef,
useState,
} from 'react';
import { createPortal } from 'react-dom';
import { useSelector } from 'react-redux';
import ClickOutside from '../ClickOutside';
import { PressTipRoot } from '../PressTip';
import { usePopper } from '../usePopper';
import ColorDestinySymbols from './ColorDestinySymbols';
import styles from './SymbolsPicker.m.scss';
Expand Down Expand Up @@ -104,6 +114,7 @@ function SymbolsPickerButton<T extends HTMLTextAreaElement | HTMLInputElement>({
const controlRef = useRef<HTMLButtonElement>(null);
const tooltipContents = useRef<HTMLDivElement>(null);
const [open, setOpen] = useState(false);
const pressTipRoot = useContext(PressTipRoot);

usePopper({
contents: tooltipContents,
Expand Down Expand Up @@ -150,15 +161,15 @@ function SymbolsPickerButton<T extends HTMLTextAreaElement | HTMLInputElement>({
>
<span>{symbolsIcon}</span>
</button>
{open && (
<Portal>
<div ref={tooltipContents} style={{ zIndex: 20 }}>
{open &&
createPortal(
<div ref={tooltipContents}>
<ClickOutside onClickOutside={() => setOpen(false)}>
<SymbolsWindow onChooseGlyph={onChooseGlyph} />
</ClickOutside>
</div>
</Portal>
)}
</div>,
pressTipRoot.current ?? tempContainer
)}
</>
);
}
3 changes: 2 additions & 1 deletion src/app/dim-ui/useDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import styles from './useDialog.m.scss';
import { Portal } from 'app/utils/temp-container';
import clsx from 'clsx';
import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
import ClickOutsideRoot from './ClickOutsideRoot';

// Redecalare forwardRef
declare module 'react' {
Expand Down Expand Up @@ -101,7 +102,7 @@ const Dialog = forwardRef(function Dialog<Args = [], Result = void>(
onClose={handleCloseEvent}
onClick={(e) => e.stopPropagation()}
>
{dialogState && children(dialogState.args, close)}
<ClickOutsideRoot>{dialogState && children(dialogState.args, close)}</ClickOutsideRoot>
</dialog>
</Portal>
);
Expand Down

0 comments on commit df57a66

Please sign in to comment.