diff --git a/CHANGELOG.md b/CHANGELOG.md index 875db91d3e1..7175427c326 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ No public interface changes since `0.0.15`. +**Bug fixes** + +- Stop propagation and prevent default when closing components. Otherwise the same Escape keypress could close the parent component(s) as well as the one you intend to close. [(#344)](https://github.com/elastic/eui/pull/344) + # [`0.0.15`](https://github.com/elastic/eui/tree/v0.0.15) - Added `EuiColorPicker`. ((328)[https://github.com/elastic/eui/pull/328]) diff --git a/src/components/code/_code_block.js b/src/components/code/_code_block.js index 60de6a46a61..ba7d293640c 100644 --- a/src/components/code/_code_block.js +++ b/src/components/code/_code_block.js @@ -58,6 +58,8 @@ export class EuiCodeBlockImpl extends Component { onKeyDown = event => { if (event.keyCode === keyCodes.ESCAPE) { + event.preventDefault(); + event.stopPropagation(); this.closeFullScreen(); } }; diff --git a/src/components/context_menu/context_menu_panel.js b/src/components/context_menu/context_menu_panel.js index 71d862212a3..b2e232f3d6e 100644 --- a/src/components/context_menu/context_menu_panel.js +++ b/src/components/context_menu/context_menu_panel.js @@ -88,6 +88,8 @@ export class EuiContextMenuPanel extends Component { ) { if (e.keyCode === cascadingMenuKeyCodes.LEFT) { if (this.props.showPreviousPanel) { + e.preventDefault(); + e.stopPropagation(); this.props.showPreviousPanel(); if (this.props.onUseKeyboardToNavigate) { diff --git a/src/components/flyout/flyout.js b/src/components/flyout/flyout.js index a68487c72ca..fe799cbd33d 100644 --- a/src/components/flyout/flyout.js +++ b/src/components/flyout/flyout.js @@ -22,6 +22,8 @@ export const SIZES = Object.keys(sizeToClassNameMap); export class EuiFlyout extends Component { onKeyDown = event => { if (event.keyCode === keyCodes.ESCAPE) { + event.preventDefault(); + event.stopPropagation(); this.props.onClose(); } }; diff --git a/src/components/image/image.js b/src/components/image/image.js index e72bab7238c..ac74dfbb19e 100644 --- a/src/components/image/image.js +++ b/src/components/image/image.js @@ -42,6 +42,8 @@ export class EuiImage extends Component { onKeyDown = event => { if (event.keyCode === keyCodes.ESCAPE) { + event.preventDefault(); + event.stopPropagation(); this.closeFullScreen(); } }; diff --git a/src/components/modal/modal.js b/src/components/modal/modal.js index ef19e336ecf..e2d1a326d66 100644 --- a/src/components/modal/modal.js +++ b/src/components/modal/modal.js @@ -10,6 +10,8 @@ import { keyCodes } from '../../services'; export class EuiModal extends Component { onKeyDown = event => { if (event.keyCode === keyCodes.ESCAPE) { + event.preventDefault(); + event.stopPropagation(); this.props.onClose(); } }; diff --git a/src/components/popover/popover.js b/src/components/popover/popover.js index 2688bceff63..b45fe2d4b94 100644 --- a/src/components/popover/popover.js +++ b/src/components/popover/popover.js @@ -44,6 +44,8 @@ export class EuiPopover extends Component { onKeyDown = e => { if (e.keyCode === cascadingMenuKeyCodes.ESCAPE) { + e.preventDefault(); + e.stopPropagation(); this.props.closePopover(); } };