-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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(volume-panel): a long press on the volume button displays the volume slider on touch devices #8361
Conversation
…ume slider on touch devices Prevents the `volume slider` from displaying when a long press is made on the `volume button`, forcing the user to make a long press or tap elsewhere on the player or page to make the `volume slider` disappear. - adds class `.vjs-touch-enabled` to pseudo-class `:not` at the root of the rule displaying the `volume slider`
Codecov Report
@@ Coverage Diff @@
## main #8361 +/- ##
==========================================
+ Coverage 82.69% 82.71% +0.01%
==========================================
Files 113 113
Lines 7578 7578
Branches 1821 1821
==========================================
+ Hits 6267 6268 +1
+ Misses 1311 1310 -1 see 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
ObservationAlthough the fix seems trivial, it does have an impact on touch-screen laptops such as Chromebooks, Microsoft Surface and ThinkPad Yoga (yet to be confirmed). On these devices, hovering over the volume button won't display the volume slider. The main reason for this is how a touch device is detected, see: video.js/src/js/utils/browser.js Lines 150 to 153 in c66bf40
One approach would be to use the matchMedia API 1. 2., which could potentially target only mobile devices such as smartphones and tablets: export const TOUCH_ENABLED = Boolean(Dom.isReal()) &&
window.matchMedia('(pointer: coarse)').matches &&
window.matchMedia('(any-pointer: coarse)').matches; If the above code more accurately reflects the original intention, a separate PR could be made. This would allow the fix proposed in this PR to work in all the cases tested below. TestIf a test does not explicitly indicate Browserstack, this means that it was run on a real device. If the test indicates more than one browser per device, this means that different results were found. Galaxy note (Browserstack)
Lenovo Tab P11 Plus
iPad (Browserstack), iPhone, "regular" Android Smartphones
Chromebook with touch screen
|
That version of |
I agree that the 90% of the time, people treat it as a proxy for phone/tablet touch device, but, as you point out, it includes hybrid devices like the Surface. Further, I think a lot of users are probably relying on the current behavior of What might be better is to have a different value/class name for mobile/tablet devices where they are detected (either via It seems to me what we really care about is how the user is interacting with a control. This could be through touch input, mouse input, or keyboard input. The complexity comes in because touch and mouse input intersect in how they get handled in the UI. A backward compatible way might be to do device type detection (using Kind of thinking out loud here. |
Thank you for taking the time to read and respond to my comment. @mister-ben, I had indeed missed this case, which shows that my approach was not the right one. @misteroneill, I really like your proposal for the various reasons you mentioned and for the improvement it would bring to developers. My only concern is that one demonstrated by mister-ben, where we see that some devices don't necessarily return consistent information. If we add on top of that the differences that can exist on the same device with different browsers, exotic UAs that don't make it easy to clearly distinguish the type of device, and future limitations on UAs. This seems to me to be a substantial piece of work, potentially difficult to maintain and perhaps requiring the creation of a new repo so as not to clutter up the original code base too much. In any case, thank you once again for your comments, which have given me the answer to the question I was asking myself: should I close this PR? The answer is: yes So I'm closing this PR, which can be reopened if needed. |
Description
Prevents the
volume slider
from displaying when a long press is made on thevolume button
, forcing the user to make a long press or tap elsewhere on the player or page to make thevolume slider
disappear.Screencast.from.16.07.23.13.24.51.webm
Refers to #8320 (comment)
Specific Changes proposed
.vjs-touch-enabled
to pseudo-class:not
at the root of the rule displaying thevolume slider
Requirements Checklist