Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zIndexAdjustment prop to EuiPopover #1097

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Added `string` to allowed `restrictWidth` prop type of `EuiPage` and `EuiPageBody` ([#1090](https://github.com/elastic/eui/pull/1090))
- Added `.eui-textBreakNormal` and `@mixin euiTextTruncate` as CSS/SASS utilities ([#1092](https://github.com/elastic/eui/pull/1092))
- Added `fullWidth` support to `EuiComboBox` ([#1095](https://github.com/elastic/eui/pull/1095))
- Added `zIndexAdjustment` to `EuiPopover` which allows tweaking the popover content's `z-index` ([#1097](https://github.com/elastic/eui/pull/1097))

**Bug fixes**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ exports[`CollapsedItemActions render 1`] = `
ownFocus={false}
panelPaddingSize="none"
popoverRef={[Function]}
zIndexAdjustment={0}
>
<EuiContextMenuPanel
hasFocus={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ exports[`EuiInMemoryTable behavior pagination 1`] = `
ownFocus={false}
panelPaddingSize="none"
withTitle={true}
zIndexAdjustment={0}
>
<EuiOutsideClickDetector
onOutsideClick={[Function]}
Expand Down
6 changes: 5 additions & 1 deletion src/components/popover/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export class EuiPopover extends Component {
// the popover's z-index must inherit from the button
// this keeps a button's popover under a flyout that would cover the button
// but a popover triggered inside a flyout will appear over that flyout
const zIndex = getElementZIndex(this.button, this.panel);
const zIndex = getElementZIndex(this.button, this.panel) + this.props.zIndexAdjustment;

const popoverStyles = {
top,
Expand Down Expand Up @@ -307,6 +307,7 @@ export class EuiPopover extends Component {
panelClassName,
panelPaddingSize,
popoverRef,
zIndexAdjustment, // eslint-disable-line no-unused-vars
...rest
} = this.props;

Expand Down Expand Up @@ -436,11 +437,14 @@ EuiPopover.propTypes = {
]),
/** When `true`, the popover's position is re-calculated when the user scrolls, this supports having fixed-position popover anchors. */
repositionOnScroll: PropTypes.bool,
/** Popover content inherits the z-index of the anchor component, zIndexAdjustment is added to this z-index */
zIndexAdjustment: PropTypes.number,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel strongly about this but I think I've seen "offset" used more often to indicate a value that's added to an original value, e.g. offsetX. Just tossing it out there if you feel it's more descriptive. I'm OK with "adjustment" too as long as it's used consistently for similar variable names elsewhere.

};

EuiPopover.defaultProps = {
isOpen: false,
ownFocus: false,
anchorPosition: 'downCenter',
panelPaddingSize: 'm',
zIndexAdjustment: 0,
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ exports[`FieldValueSelectionFilter render - all configurations 1`] = `
panelClassName="euiFilterGroup__popoverPanel"
panelPaddingSize="none"
withTitle={null}
zIndexAdjustment={0}
>
<div
className="euiFilterSelect__note"
Expand Down Expand Up @@ -68,6 +69,7 @@ exports[`FieldValueSelectionFilter render - multi-select OR 1`] = `
panelClassName="euiFilterGroup__popoverPanel"
panelPaddingSize="none"
withTitle={null}
zIndexAdjustment={0}
>
<div
className="euiFilterSelect__note"
Expand Down Expand Up @@ -113,6 +115,7 @@ exports[`FieldValueSelectionFilter render - options as a function 1`] = `
panelClassName="euiFilterGroup__popoverPanel"
panelPaddingSize="none"
withTitle={null}
zIndexAdjustment={0}
>
<div
className="euiFilterSelect__note"
Expand Down Expand Up @@ -158,6 +161,7 @@ exports[`FieldValueSelectionFilter render - options as an array 1`] = `
panelClassName="euiFilterGroup__popoverPanel"
panelPaddingSize="none"
withTitle={null}
zIndexAdjustment={0}
>
<div
className="euiFilterSelect__note"
Expand Down
6 changes: 3 additions & 3 deletions src/services/popover/popover_positioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ export function intersectBoundingBoxes(firstBox, secondBox) {
* relative to the `target` element; if no z-index is defined, returns "0"
* @param element {HTMLElement|React.Component}
* @param cousin {HTMLElement|React.Component}
* @returns {string}
* @returns {number}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to count this as a breaking change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is only internal.

Copy link
Contributor

@cjcenizal cjcenizal Aug 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hear ya, just thought I would ask because technically consumers can access it like this:

import { getElementZIndex } from '@elastic/eui/lib/services/popover/popover_positioning';

Kibana is accessing the contents of other modules like this, which I'm not a fan of, but I'm not sure if our docs or conventions are clear about how to distinguish public from internal services. No big deal, just thought I'd mention it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ughhh; true. In response to Caroline's request I've reverted the changes to this function, but you're right with the deep-importing that could happen this would be a breaking change.

*/
export function getElementZIndex(element, cousin) {
element = findDOMNode(element);
Expand Down Expand Up @@ -567,8 +567,8 @@ export function getElementZIndex(element, cousin) {
const zIndex = window.document.defaultView.getComputedStyle(node).getPropertyValue('z-index');

// if the z-index is not a number (e.g. "auto") return null, else the value
return isNaN(zIndex) ? null : zIndex;
return isNaN(zIndex) ? null : parseInt(zIndex, 10);
},
null
) || '0';
) || 0;
}