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 event target checker for EuiOverlayMask's onClick prop #3462

Merged
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Added exports for `EuiSteps` and related components types ([#3471](https://github.com/elastic/eui/pull/3471))
- Added `displayName` to components using `React.forwardRef` ([#3451](https://github.com/elastic/eui/pull/3451))
- Added event target checker for `EuiOverlayMask`'s `onClick` prop ([#3462](https://github.com/elastic/eui/pull/3462))

## [`24.0.0`](https://github.com/elastic/eui/tree/v24.0.0)

Expand All @@ -11,12 +12,12 @@
- Added `partition` key to `EuiChartThemeType` for Partition chart support ([#3387](https://github.com/elastic/eui/pull/3387))
- Updated `EuiImage`'s `caption` prop type from `string` to `ReactNode` ([#3387](https://github.com/elastic/eui/pull/3387))
- Improved contrast for `EuiCollapsibleNav` close button ([#3465](https://github.com/elastic/eui/pull/3465))
- Fixed `EuiCodeEditor` console error when using the editor without import the default theme ([#3454](https://github.com/elastic/eui/pull/3454))
- Added exports for `EuiSteps` and related components types ([#3471](https://github.com/elastic/eui/pull/3471))

**Bug Fixes**

- Fixed `EuiSuperDatePicker` quick selection menu overriding specified time range with default values ([#3446](https://github.com/elastic/eui/pull/3446))
- Fixed `EuiCodeEditor` console error when using the editor without import the default theme ([#3454](https://github.com/elastic/eui/pull/3454))
- Fixed `EuiDatePopoverContent` `onChange` event to only accept `string` date input ([#3460](https://github.com/elastic/eui/pull/3460))

**Breaking changes**
Expand Down
7 changes: 2 additions & 5 deletions src-docs/src/views/modal/overflow_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { useState } from 'react';

import {
EuiButton,
EuiButtonEmpty,
EuiModal,
EuiModalBody,
EuiModalFooter,
Expand All @@ -22,7 +21,7 @@ export default () => {

if (isModalVisible) {
modal = (
<EuiOverlayMask>
<EuiOverlayMask onClick={closeModal}>
<EuiModal onClose={closeModal}>
<EuiModalHeader>
<EuiModalHeaderTitle>Overflow test</EuiModalHeaderTitle>
Expand Down Expand Up @@ -73,10 +72,8 @@ export default () => {
</EuiModalBody>

<EuiModalFooter>
<EuiButtonEmpty onClick={closeModal}>Cancel</EuiButtonEmpty>

<EuiButton onClick={closeModal} fill>
Save
Close
</EuiButton>
</EuiModalFooter>
</EuiModal>
Expand Down
9 changes: 8 additions & 1 deletion src/components/overlay_mask/overlay_mask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ export class EuiOverlayMask extends Component<Props> {
this.overlayMaskNode = document.createElement('div');
this.overlayMaskNode.className = classNames('euiOverlayMask', className);
if (onClick) {
this.overlayMaskNode.addEventListener('click', onClick);
this.overlayMaskNode.addEventListener(
'click',
(e: React.MouseEvent | MouseEvent) => {
if (e.target === this.overlayMaskNode) {
onClick();
}
}
);
}
keysOf(rest).forEach(key => {
if (typeof rest[key] !== 'string') {
Expand Down