Skip to content

Commit

Permalink
Popper spectrum provider + positioning (deephaven#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmingles committed Mar 6, 2024
1 parent 9280b73 commit 5a5445f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
39 changes: 21 additions & 18 deletions packages/components/src/popper/Popper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import PopperJs, { PopperOptions, ReferenceObject } from 'popper.js';
import PropTypes from 'prop-types';
import ThemeExport from '../ThemeExport';
import './Popper.scss';
import { SpectrumThemeProvider } from '../theme/SpectrumThemeProvider';

interface PopperProps {
options: PopperOptions;
Expand Down Expand Up @@ -251,25 +252,27 @@ class Popper extends Component<PopperProps, PopperState> {
onEntered={this.handleEnter}
onExited={this.handleExit}
>
<div
onClick={e => {
// stop click events from escaping popper
e.stopPropagation();
}}
onKeyDown={e => {
if (e.key === 'Escape') this.hide();
}}
className={classNames('popper', { interactive }, className)}
onBlur={closeOnBlur ? this.handleBlur : undefined}
tabIndex={closeOnBlur ? -1 : undefined}
role="presentation"
>
<div className="popper-content">
{children}
{/* eslint-disable-next-line react/no-unknown-property */}
<div className="popper-arrow" x-arrow="" />
<SpectrumThemeProvider isPortal>
<div
onClick={e => {
// stop click events from escaping popper
e.stopPropagation();
}}
onKeyDown={e => {
if (e.key === 'Escape') this.hide();
}}
className={classNames('popper', { interactive }, className)}
onBlur={closeOnBlur ? this.handleBlur : undefined}
tabIndex={closeOnBlur ? -1 : undefined}
role="presentation"
>
<div className="popper-content">
{children}
{/* eslint-disable-next-line react/no-unknown-property */}
<div className="popper-arrow" x-arrow="" />
</div>
</div>
</div>
</SpectrumThemeProvider>
</CSSTransition>
);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/spectrum/picker/PickerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@ export function normalizePickerItemList(
*/
export function normalizeTooltipOptions(
options?: boolean | TooltipOptions | null
): PopperOptions | null {
): TooltipOptions | null {
if (options == null || options === false) {
return null;
}

if (options === true) {
return { placement: 'top-start' };
return { placement: 'right' };
}

return options;
Expand Down

0 comments on commit 5a5445f

Please sign in to comment.