Skip to content

Commit

Permalink
Properly cancel keydown events after handling (#344)
Browse files Browse the repository at this point in the history
* Properly cancel keydown events after handling

* Add changelog entry

* Add missing components
  • Loading branch information
timroes authored Feb 6, 2018
1 parent 6a9d9c0 commit 1d633bf
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

- Added `react-color` as a dependency (was previously a devDependency) ([#354](https://github.com/elastic/eui/pull/354))

**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))
Expand Down
2 changes: 2 additions & 0 deletions src/components/code/_code_block.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export class EuiCodeBlockImpl extends Component {

onKeyDown = event => {
if (event.keyCode === keyCodes.ESCAPE) {
event.preventDefault();
event.stopPropagation();
this.closeFullScreen();
}
};
Expand Down
2 changes: 2 additions & 0 deletions src/components/context_menu/context_menu_panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/components/flyout/flyout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};
Expand Down
2 changes: 2 additions & 0 deletions src/components/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export class EuiImage extends Component {

onKeyDown = event => {
if (event.keyCode === keyCodes.ESCAPE) {
event.preventDefault();
event.stopPropagation();
this.closeFullScreen();
}
};
Expand Down
2 changes: 2 additions & 0 deletions src/components/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};
Expand Down
2 changes: 2 additions & 0 deletions src/components/popover/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export class EuiPopover extends Component {

onKeyDown = e => {
if (e.keyCode === cascadingMenuKeyCodes.ESCAPE) {
e.preventDefault();
e.stopPropagation();
this.props.closePopover();
}
};
Expand Down

0 comments on commit 1d633bf

Please sign in to comment.