File tree 2 files changed +7
-10
lines changed
packages/material-ui/src/Modal
2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -156,16 +156,13 @@ class Modal extends React.Component {
156
156
} ;
157
157
158
158
handleKeyDown = event => {
159
- // event.defaultPrevented:
159
+ // We don't take event.defaultPrevented into account :
160
160
//
161
- // Ignore events that have been `event.preventDefault()` marked.
162
- // preventDefault() is meant to stop default behaviours like
161
+ // event.preventDefault() is meant to stop default behaviours like
163
162
// clicking a checkbox to check it, hitting a button to submit a form,
164
163
// and hitting left arrow to move the cursor in a text input etc.
165
- // Only special HTML elements have these default bahaviours.
166
- //
167
- // To remove in v4.
168
- if ( event . key !== 'Escape' || ! this . isTopModal ( ) || event . defaultPrevented ) {
164
+ // Only special HTML elements have these default behaviors.
165
+ if ( event . key !== 'Escape' || ! this . isTopModal ( ) ) {
169
166
return ;
170
167
}
171
168
Original file line number Diff line number Diff line change @@ -324,15 +324,15 @@ describe('<Modal />', () => {
324
324
assert . strictEqual ( onCloseSpy . callCount , 0 ) ;
325
325
} ) ;
326
326
327
- it ( 'should not be call when defaultPrevented' , ( ) => {
327
+ it ( 'should be call when defaultPrevented' , ( ) => {
328
328
topModalStub . returns ( true ) ;
329
329
wrapper . setProps ( { disableEscapeKeyDown : true , manager : { isTopModal : topModalStub } } ) ;
330
330
event = { key : 'Escape' , defaultPrevented : true } ;
331
331
332
332
instance . handleKeyDown ( event ) ;
333
333
assert . strictEqual ( topModalStub . callCount , 1 ) ;
334
- assert . strictEqual ( onEscapeKeyDownSpy . callCount , 0 ) ;
335
- assert . strictEqual ( onCloseSpy . callCount , 0 ) ;
334
+ assert . strictEqual ( onEscapeKeyDownSpy . callCount , 1 ) ;
335
+ assert . strictEqual ( onCloseSpy . callCount , 1 ) ;
336
336
} ) ;
337
337
} ) ;
338
338
You can’t perform that action at this time.
0 commit comments