Skip to content

Commit

Permalink
fix: dont compute maxHeight of popover on horizontal placement
Browse files Browse the repository at this point in the history
  • Loading branch information
chenesan committed Oct 26, 2022
1 parent 722aede commit 581fc6c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion packages/core/src/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import closable from './mixins/closable';
import renderToLayer from './mixins/renderToLayer';

import './styles/Popover.scss';
import { verticalPlacements } from './mixins/anchored/getPositionState';

export const COMPONENT_NAME = prefixClass('popover');
const ROOT_BEM = icBEM(COMPONENT_NAME);
Expand Down Expand Up @@ -48,7 +49,11 @@ function Popover({
* The `maxHeight` is for `BEM.container`, which doesn't include root class padding.
* So we need to minus POPOVER_PADDING here.
*/
const maxHeight = remainingSpace ? remainingSpace - POPOVER_PADDING : undefined;
const maxHeight = (
(remainingSpace && verticalPlacements.includes(placement))
? remainingSpace - POPOVER_PADDING
: undefined
);

const handleWrapperClick = (event) => {
onInsideClick(event);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/mixins/anchored/getPositionState.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import PLACEMENT from './constants/placement';

export { PLACEMENT };
const { TOP, BOTTOM, LEFT, RIGHT } = PLACEMENT;
const verticalPlacements = [TOP, BOTTOM];
const horizontalPlacements = [LEFT, RIGHT];
export const verticalPlacements = [TOP, BOTTOM];
export const horizontalPlacements = [LEFT, RIGHT];

/**
* @typedef {typeof TOP| typeof BOTTOM} Placement
Expand Down

0 comments on commit 581fc6c

Please sign in to comment.