-
Notifications
You must be signed in to change notification settings - Fork 667
Popup: Close popup on Escape key press when focus is inside a child editor #32957
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
Merged
marker-dao
merged 8 commits into
DevExpress:26_1
from
r-farkhutdinov:26_1_popup_esc_handle
Mar 20, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d275e25
Popup: Close popup on Escape key press when focus is inside a child e…
ad71ff2
Popup: Add unit test to ensure nested editors closing correctly
r-farkhutdinov 3de341b
Popup: Support _ignoreCloseOnChildEscape option
f5448c8
Popup: Add !onlyChildProcessing check for hiding
e99179e
Grid: Add _ignoreCloseOnChildEscape to Popup init in columnChooser
002c48d
refactor(popup): Add default value
b345faa
refactor(minor)
c6649b5
feat(tests): Add _ignoreCloseOnChildEscape to the skip
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import type { Meta, StoryObj } from '@storybook/react-webpack5'; | ||
| import React, { useCallback, useState } from 'react'; | ||
|
|
||
| import { Button } from 'devextreme-react/button'; | ||
| import { DateBox } from 'devextreme-react/date-box'; | ||
| import { Popup } from 'devextreme-react/popup'; | ||
| import { SelectBox } from 'devextreme-react/select-box'; | ||
| import { TextBox } from 'devextreme-react/text-box'; | ||
| import { categories, products } from './data'; | ||
|
|
||
| const meta: Meta<typeof Popup> = { | ||
| title: 'Components/Popup', | ||
| component: Popup, | ||
| parameters: { | ||
| layout: 'padded', | ||
| }, | ||
| }; | ||
|
|
||
| export default meta; | ||
|
|
||
| type Story = StoryObj<typeof Popup>; | ||
|
|
||
| const EscapeFromEditorsExample: Story['render'] = () => { | ||
| const [visible, setVisible] = useState(false); | ||
| const [selectedProduct, setSelectedProduct] = useState(products[0]); | ||
| const [category, setCategory] = useState(categories[0]); | ||
|
|
||
| const show = useCallback(() => setVisible(true), []); | ||
| const hide = useCallback(() => setVisible(false), []); | ||
|
|
||
| return ( | ||
| <div style={{ padding: 24 }}> | ||
| <p style={{ marginBottom: 16, color: '#555' }}> | ||
| Open the popup and focus any editor. Press Escape - the popup | ||
| should close even when focus is inside a TextBox, SelectBox, or DateBox. | ||
| </p> | ||
| <Button text="Open Popup" type="default" onClick={show} /> | ||
|
|
||
| <Popup | ||
| visible={visible} | ||
| onHiding={hide} | ||
| title="Edit Product" | ||
| width={420} | ||
| height="auto" | ||
| hideOnOutsideClick | ||
| showCloseButton | ||
| toolbarItems={[ | ||
| { | ||
| widget: 'dxButton', | ||
| toolbar: 'bottom', | ||
| location: 'after', | ||
| options: { | ||
| text: 'Save', | ||
| type: 'default', | ||
| stylingMode: 'contained', | ||
| onClick: hide, | ||
| }, | ||
| }, | ||
| { | ||
| widget: 'dxButton', | ||
| toolbar: 'bottom', | ||
| location: 'after', | ||
| options: { | ||
| text: 'Cancel', | ||
| stylingMode: 'outlined', | ||
| onClick: hide, | ||
| }, | ||
| }, | ||
| ]} | ||
| > | ||
| <div style={{ display: 'flex', flexDirection: 'column', gap: 12, padding: '8px 0' }}> | ||
| <TextBox | ||
| label="Product" | ||
| value={selectedProduct.text} | ||
| onValueChanged={(e) => setSelectedProduct({ ...selectedProduct, text: e.value })} | ||
| /> | ||
| <SelectBox | ||
| label="Category" | ||
| items={categories} | ||
| value={category} | ||
| onValueChanged={(e) => setCategory(e.value)} | ||
| /> | ||
| <DateBox | ||
| label="Available From" | ||
| type="date" | ||
| defaultValue={new Date(2024, 0, 1)} | ||
| /> | ||
| </div> | ||
| </Popup> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export const EscapeFromEditors: Story = { | ||
| name: 'Popup - Escape handling', | ||
| render: EscapeFromEditorsExample, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| export const categories = ['Video Players', 'Televisions', 'Monitors', 'Projectors']; | ||
|
|
||
| export const products = [ | ||
| { id: '1_1', text: 'HD Video Player', category: 'Video Players', price: 220 }, | ||
| { id: '1_2', text: 'SuperHD Video Player', category: 'Video Players', price: 270 }, | ||
| { id: '2_1', text: 'SuperLCD 42', category: 'Televisions', price: 1200 }, | ||
| { id: '2_2', text: 'SuperLED 42', category: 'Televisions', price: 1450 }, | ||
| { id: '3_1_1', text: 'DesktopLCD 19', category: 'Monitors', price: 160 }, | ||
| { id: '3_2_1', text: 'DesktopLCD 21', category: 'Monitors', price: 170 }, | ||
| { id: '4_1', text: 'Projector Plus', category: 'Projectors', price: 550 }, | ||
| { id: '4_2', text: 'Projector PlusHD', category: 'Projectors', price: 750 }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should set a default value for this property as well, just as we do for all the others.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved 002c48d