Skip to content

Commit ea07907

Browse files
authoredApr 4, 2025··
fix(UI): Don't allow click on the buttons when the UI is not visible (#8396)
1 parent ecfec60 commit ea07907

19 files changed

+64
-0
lines changed
 

‎demo/close_button.js

+4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ shakaDemo.CloseButton = class extends shaka.ui.Element {
2323
super(parent, controls);
2424
this.button_ = document.createElement('button');
2525
this.button_.classList.add('material-icons-round');
26+
this.button_.classList.add('shaka-no-propagation');
2627
this.button_.classList.add('close-button');
2728
this.button_.textContent = 'close'; // Close icon.
2829
this.parent.appendChild(this.button_);
2930

3031
this.button_.addEventListener('click', () => {
32+
if (!this.controls.isOpaque()) {
33+
return;
34+
}
3135
shakaDemoMain.unload();
3236
});
3337

‎ui/ad_statistics_button.js

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ shaka.ui.AdStatisticsButton = class extends shaka.ui.Element {
127127
});
128128

129129
this.eventManager.listen(this.button_, 'click', () => {
130+
if (!this.controls.isOpaque()) {
131+
return;
132+
}
130133
this.onClick_();
131134
this.updateLocalizedStrings_();
132135
});

‎ui/airplay_button.js

+3
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ shaka.ui.AirPlayButton = class extends shaka.ui.Element {
8181
});
8282

8383
this.eventManager.listen(this.airplayButton_, 'click', () => {
84+
if (!this.controls.isOpaque()) {
85+
return;
86+
}
8487
this.onAirPlayClick_();
8588
});
8689

‎ui/cast_button.js

+3
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ shaka.ui.CastButton = class extends shaka.ui.Element {
8181
});
8282

8383
this.eventManager.listen(this.castButton_, 'click', () => {
84+
if (!this.controls.isOpaque()) {
85+
return;
86+
}
8487
this.onCastClick_();
8588
});
8689

‎ui/chapter_selection.js

+3
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ shaka.ui.ChapterSelection = class extends shaka.ui.SettingsMenu {
154154
button.appendChild(span);
155155

156156
this.eventManager.listen(button, 'click', () => {
157+
if (!this.controls.isOpaque()) {
158+
return;
159+
}
157160
this.video.currentTime = chapter.startTime;
158161
});
159162

‎ui/controls.js

+9
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,15 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
406406
const cb = (event) => event.stopPropagation();
407407
this.eventManager_.listen(element, 'click', cb);
408408
this.eventManager_.listen(element, 'dblclick', cb);
409+
if (navigator.maxTouchPoints > 0) {
410+
const touchCb = (event) => {
411+
if (!this.isOpaque()) {
412+
return;
413+
}
414+
event.stopPropagation();
415+
};
416+
this.eventManager_.listen(element, 'touchend', touchCb);
417+
}
409418
}
410419
}
411420

‎ui/fast_forward_button.js

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ shaka.ui.FastForwardButton = class extends shaka.ui.Element {
5353
});
5454

5555
this.eventManager.listen(this.button_, 'click', () => {
56+
if (!this.controls.isOpaque()) {
57+
return;
58+
}
5659
this.fastForward_();
5760
});
5861
}

‎ui/fullscreen_button.js

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ shaka.ui.FullscreenButton = class extends shaka.ui.Element {
5555
});
5656

5757
this.eventManager.listen(this.button_, 'click', async () => {
58+
if (!this.controls.isOpaque()) {
59+
return;
60+
}
5861
await this.controls.toggleFullScreen();
5962
});
6063

‎ui/loop_button.js

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ shaka.ui.LoopButton = class extends shaka.ui.Element {
7373
});
7474

7575
this.eventManager.listen(this.button_, 'click', () => {
76+
if (!this.controls.isOpaque()) {
77+
return;
78+
}
7679
this.onClick_();
7780
});
7881

‎ui/mute_button.js

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ shaka.ui.MuteButton = class extends shaka.ui.Element {
7272
});
7373

7474
this.eventManager.listen(this.button_, 'click', () => {
75+
if (!this.controls.isOpaque()) {
76+
return;
77+
}
7578
if (this.ad && this.ad.isLinear()) {
7679
this.ad.setMuted(!this.ad.isMuted());
7780
} else {

‎ui/overflow_menu.js

+3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ shaka.ui.OverflowMenu = class extends shaka.ui.Element {
8686
});
8787

8888
this.eventManager.listen(this.overflowMenuButton_, 'click', () => {
89+
if (!this.controls.isOpaque()) {
90+
return;
91+
}
8992
this.onOverflowMenuButtonClick_();
9093
});
9194

‎ui/pip_button.js

+3
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ shaka.ui.PipButton = class extends shaka.ui.Element {
8787
});
8888

8989
this.eventManager.listen(this.pipButton_, 'click', () => {
90+
if (!this.controls.isOpaque()) {
91+
return;
92+
}
9093
this.controls.togglePiP();
9194
});
9295

‎ui/play_button.js

+3
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ shaka.ui.PlayButton = class extends shaka.ui.Element {
7777
});
7878

7979
this.eventManager.listen(this.button, 'click', () => {
80+
if (!this.controls.isOpaque()) {
81+
return;
82+
}
8083
this.controls.playPausePresentation();
8184
});
8285

‎ui/presentation_time.js

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ shaka.ui.PresentationTimeTracker = class extends shaka.ui.Element {
3535
this.parent.appendChild(this.currentTime_);
3636

3737
this.eventManager.listen(this.currentTime_, 'click', () => {
38+
if (!this.controls.isOpaque()) {
39+
return;
40+
}
3841
// Jump to LIVE if the user clicks on the current time.
3942
if (this.player.isLive()) {
4043
this.video.currentTime = this.player.seekRange().end;

‎ui/recenter_vr.js

+3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ shaka.ui.RecenterVRButton = class extends shaka.ui.Element {
7474
const vr = this.controls.getVR();
7575

7676
this.eventManager.listen(this.recenterVRButton_, 'click', () => {
77+
if (!this.controls.isOpaque()) {
78+
return;
79+
}
7780
vr.reset();
7881
});
7982

‎ui/remote_button.js

+3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ shaka.ui.RemoteButton = class extends shaka.ui.Element {
9090
});
9191

9292
this.eventManager.listen(this.remoteButton_, 'click', () => {
93+
if (!this.controls.isOpaque()) {
94+
return;
95+
}
9396
this.video.remote.prompt();
9497
});
9598

‎ui/rewind_button.js

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ shaka.ui.RewindButton = class extends shaka.ui.Element {
5454
});
5555

5656
this.eventManager.listen(this.button_, 'click', () => {
57+
if (!this.controls.isOpaque()) {
58+
return;
59+
}
5760
this.rewind_();
5861
});
5962
}

‎ui/settings_menu.js

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ shaka.ui.SettingsMenu = class extends shaka.ui.Element {
3737
this.inOverflowMenu_();
3838

3939
this.eventManager.listen(this.button, 'click', () => {
40+
if (!this.controls.isOpaque()) {
41+
return;
42+
}
4043
this.onButtonClick_();
4144
});
4245
}

‎ui/toggle_stereoscopic.js

+3
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ shaka.ui.ToggleStereoscopicButton = class extends shaka.ui.Element {
7575
const vr = this.controls.getVR();
7676

7777
this.eventManager.listen(this.toggleStereoscopicButton_, 'click', () => {
78+
if (!this.controls.isOpaque()) {
79+
return;
80+
}
7881
vr.toggleStereoscopicMode();
7982
});
8083

0 commit comments

Comments
 (0)
Please sign in to comment.