Skip to content
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

fix: fullWindowOnEscKey handler #7224

Merged
merged 1 commit into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});