File tree Expand file tree Collapse file tree
testing/tests/DevExpress.ui.widgets Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -180,6 +180,8 @@ export interface PopupProperties extends Properties {
180180 useDefaultToolbarButtons ?: boolean ;
181181
182182 useFlatToolbarButtons ?: boolean ;
183+
184+ _ignoreCloseOnChildEscape ?: boolean ;
183185}
184186
185187class Popup <
@@ -227,18 +229,19 @@ class Popup<
227229 }
228230
229231 _keyboardHandler ( options : KeyboardKeyDownEvent , onlyChildProcessing ?: boolean ) : void {
230- if ( ! onlyChildProcessing ) {
231- const e = options . originalEvent ;
232- const $target = $ ( e . target ) ;
232+ // eslint-disable-next-line @typescript-eslint/naming-convention
233+ const { _ignoreCloseOnChildEscape } = this . option ( ) ;
234+ const e = options . originalEvent ;
235+ const $target = $ ( e . target ) ;
233236
234- if ( this . _$content && ! $target . is ( this . _$content )
237+ if ( this . _$content && ! $target . is ( this . _$content )
235238 && options . keyName === ESC_KEY_NAME
236- && ! e . isDefaultPrevented ( ) ) {
237- // eslint-disable-next-line @typescript-eslint/no-floating-promises
238- this . hide ( ) ;
239+ && ! e . isDefaultPrevented ( )
240+ && ! _ignoreCloseOnChildEscape ) {
241+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
242+ this . hide ( ) ;
239243
240- return ;
241- }
244+ return ;
242245 }
243246
244247 super . _keyboardHandler ( options , onlyChildProcessing ) ;
Original file line number Diff line number Diff line change @@ -286,6 +286,7 @@ export default class DropDownMenu extends Widget<DropDownMenuProperties> {
286286 showTitle : false ,
287287 fullScreen : false ,
288288 ignoreChildEvents : false ,
289+ _ignoreCloseOnChildEscape : true ,
289290 _fixWrapperPosition : true ,
290291 } ) ;
291292 this . _popup . registerKeyHandler ( 'space' , (
Original file line number Diff line number Diff line change @@ -2714,6 +2714,17 @@ QUnit.module('keyboard navigation', {
27142714
27152715 assert . strictEqual ( this . popup . option ( 'visible' ) , true , 'popup remains visible after pressing esc on a child element that prevents default' ) ;
27162716 } ) ;
2717+
2718+ QUnit . test ( 'should remain visible when child element presses escape and _ignoreCloseOnChildEscape is true' , function ( assert ) {
2719+ this . init ( { dragEnabled : false , _ignoreCloseOnChildEscape : true } ) ;
2720+
2721+ const $input = $ ( '<input>' ) . appendTo ( this . popup . $content ( ) ) ;
2722+ const keyboard = keyboardMock ( $input ) ;
2723+
2724+ keyboard . keyDown ( 'esc' ) ;
2725+
2726+ assert . strictEqual ( this . popup . option ( 'visible' ) , true , 'popup remains visible when _closeOnChildEscape is false' ) ;
2727+ } ) ;
27172728} ) ;
27182729
27192730QUnit . module ( 'rendering' , {
You can’t perform that action at this time.
0 commit comments