From 4e47b3a35a8bac1027e06c25ee0a604fc3bb00bd Mon Sep 17 00:00:00 2001 From: Sofiya Huts Date: Thu, 22 Nov 2018 12:47:48 +0100 Subject: [PATCH 1/3] Stop event propagation when press Escape on the popup --- src/components/Popup/Popup.tsx | 1 + src/lib/accessibility/Behaviors/Popup/popupBehavior.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/components/Popup/Popup.tsx b/src/components/Popup/Popup.tsx index e8b3b27e23..9d30184822 100644 --- a/src/components/Popup/Popup.tsx +++ b/src/components/Popup/Popup.tsx @@ -129,6 +129,7 @@ export default class Popup extends AutoControlledComponent this.closeAndFocusTrigger(e), + stopPropagation: e => e.stopPropagation(), } private closeAndFocusTrigger = e => { diff --git a/src/lib/accessibility/Behaviors/Popup/popupBehavior.ts b/src/lib/accessibility/Behaviors/Popup/popupBehavior.ts index 3b5ac45942..191ff541e4 100644 --- a/src/lib/accessibility/Behaviors/Popup/popupBehavior.ts +++ b/src/lib/accessibility/Behaviors/Popup/popupBehavior.ts @@ -25,6 +25,9 @@ const popupBehavior: Accessibility = (props: any) => ({ closeAndFocusTrigger: { keyCombinations: [{ keyCode: keyboardKey.Escape }], }, + stopPropagation: { + keyCombinations: [{ keyCode: keyboardKey.Escape }], + }, }, }, }) From e61d41b4c3cb54afeb2d6da49f84c9598cd65da9 Mon Sep 17 00:00:00 2001 From: Sofiya Huts Date: Thu, 22 Nov 2018 15:02:03 +0100 Subject: [PATCH 2/3] Improvements after CR comments --- src/components/Popup/Popup.tsx | 6 ++++-- src/lib/accessibility/Behaviors/Popup/popupBehavior.ts | 3 --- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/Popup/Popup.tsx b/src/components/Popup/Popup.tsx index 9d30184822..b1001185e6 100644 --- a/src/components/Popup/Popup.tsx +++ b/src/components/Popup/Popup.tsx @@ -128,8 +128,10 @@ export default class Popup extends AutoControlledComponent { this.trySetOpen(!this.state.open, e, true) }, - closeAndFocusTrigger: e => this.closeAndFocusTrigger(e), - stopPropagation: e => e.stopPropagation(), + closeAndFocusTrigger: e => { + this.closeAndFocusTrigger(e) + e.stopPropagation() + }, } private closeAndFocusTrigger = e => { diff --git a/src/lib/accessibility/Behaviors/Popup/popupBehavior.ts b/src/lib/accessibility/Behaviors/Popup/popupBehavior.ts index 191ff541e4..3b5ac45942 100644 --- a/src/lib/accessibility/Behaviors/Popup/popupBehavior.ts +++ b/src/lib/accessibility/Behaviors/Popup/popupBehavior.ts @@ -25,9 +25,6 @@ const popupBehavior: Accessibility = (props: any) => ({ closeAndFocusTrigger: { keyCombinations: [{ keyCode: keyboardKey.Escape }], }, - stopPropagation: { - keyCombinations: [{ keyCode: keyboardKey.Escape }], - }, }, }, }) From da31dcc57f2e03d7a1c90e39642a91372947ffa8 Mon Sep 17 00:00:00 2001 From: Sofiya Huts Date: Thu, 22 Nov 2018 15:37:04 +0100 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 012f4638a5..c9a63633da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Fixes - Fix the behaviour of `AutoControlledComponent` when `undefined` is passed as a prop value @layershifter ([#499](https://github.com/stardust-ui/react/pull/499)) +- Stop event propagation when press Escape on the popup @sophieH29 ([#515](https://github.com/stardust-ui/react/pull/515)) ## [v0.12.0](https://github.com/stardust-ui/react/tree/v0.12.0) (2018-11-19)