Skip to content

Commit

Permalink
fix: exit full window mode with Esc key (#7224)
Browse files Browse the repository at this point in the history
  • Loading branch information
FredZeng authored May 11, 2021
1 parent 0e46624 commit e9953e5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2979,9 +2979,11 @@ class Player extends Component {
fullWindowOnEscKey(event) {
if (keycode.isEventKey(event, 'Esc')) {
if (this.isFullscreen() === true) {
this.exitFullscreen();
} else {
this.exitFullWindow();
if (!this.isFullWindow) {
this.exitFullscreen();
} else {
this.exitFullWindow();
}
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions test/unit/player-fullscreen.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,20 @@ QUnit.test('fullscreenOptions from function args should override player options'

player.dispose();
});

QUnit.test('fullwindow mode should exit when ESC event triggered', function(assert) {
const player = FullscreenTestHelpers.makePlayer(true);

player.enterFullWindow();
assert.ok(player.isFullWindow, 'enterFullWindow should be called');

const evt = TestHelpers.createEvent('keydown');

evt.keyCode = 27;
evt.which = 27;
player.boundFullWindowOnEscKey_(evt);
// player.fullWindowOnEscKey(evt);
assert.equal(player.isFullWindow, false, 'exitFullWindow should be called');

player.dispose();
});

0 comments on commit e9953e5

Please sign in to comment.