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: Prevent ResizeManager from being clicked on safari, fix playerresize on firefox #5522

Merged
merged 5 commits into from
Oct 25, 2018

Conversation

brandonocasey
Copy link
Contributor

@brandonocasey brandonocasey commented Oct 23, 2018

Currently right clicking on the player on safari does not fire a contextmenu event, but it does on every other browser. Right clicking on the player in safari fires a contextmenu event on the ResizeManager iframe instead. The only change that needed to happen for right click to fire on the player again, was to hide ResizeManager.

EDIT:
I also found that the playerresize event does not work in Firefox. After removing visibility: hidden; it fires as we would expect, I added that change to this pull request, as I think it makes sense.

@brandonocasey brandonocasey changed the title fix: Hide ResizeManager to prevent right click hijacking on Safari fix: Prevent ResizeManager from being clicked on safari, fix playerresize on firefox Oct 23, 2018
@gkatsev
Copy link
Member

gkatsev commented Oct 24, 2018

Looks like pointer-events:none isn't good enough for this for some reason.

@gkatsev
Copy link
Member

gkatsev commented Oct 24, 2018

Looks like this doesn't fix it in safari yet, right clicking in https://deploy-preview-5522--videojs-docs.netlify.com/test-example/responsive.html in safari, I still get the menu for the iframe rather than the video element. We may need to manually make sure that the element is positioned behind the video element.

@brandonocasey
Copy link
Contributor Author

Oh I see what you mean, when the video is actually playing it gives a menu for the iframe, but before playback it gives a menu for the player. thats why I thought it was fixed. Looking further into this 👀

@brandonocasey brandonocasey force-pushed the fix/safari-contextmenu branch from 7107e62 to 388529f Compare October 24, 2018 19:42
@brandonocasey
Copy link
Contributor Author

Here is what I tried so far

  1. pointer-events: none on the iframe
  • contextmenu is still hijacked
  1. Wrap the iframe in a div and add pointer-events: none to it
  • contextmenu is still hijacked
  1. Move the iframe before the video element
  • contextmenu is not hijacked but playerresize does not work
  1. Try various visiblitiy: none/display: none on the iframe or a wrapper div
  • Causes playerresize not to fire but usually fixed the contextmenu issue

After all that I opted to re-trigger the contextmenu event on the player from the iframe, and everything appears to work as expected.

src/js/player.js Outdated
@@ -4069,15 +4069,15 @@ Player.prototype.options_ = {

// Included control sets
children: [
'resizeManager',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe revert this change if we need to re-trigger the event?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so I was going to remove this change and put resizeManager back at the bottom of the children list, but it breaks the controls for Safari. When I removed the visibility: hidden; css for the resize manager it made it so that the iframe was also intercepting other clicks on the video element. So we have to keep resizeManager at the top for controls to work correctly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we still wanted to move it, I would put it after mediaLoader.

* @param {Event} e the contextmenu event that fired
*/
handleContextmenu_(e) {
this.player_.trigger(e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we preventDefault here? Thoughts @misteroneill?

@@ -50,5 +50,5 @@
width: 100%;
height: 100%;
border: none;
visibility: hidden;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes firefox not firing playerresize

@@ -50,5 +50,5 @@
width: 100%;
height: 100%;
border: none;
visibility: hidden;
z-index: -1000;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes safari and firefox iframe contextmenu hijacking

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(firefox was started to hijack contextmenu once we removed visibility: none)

@brandonocasey brandonocasey added the needs: LGTM Needs one or more additional approvals label Oct 25, 2018
@gkatsev gkatsev merged commit 4827110 into master Oct 25, 2018
@gkatsev gkatsev deleted the fix/safari-contextmenu branch October 25, 2018 15:18
gkatsev pushed a commit that referenced this pull request Oct 31, 2018
…size on firefox (#5522)

Move the ResizeManager behind the video element with negative z-index and remove visibility: hidden. This fixes issue where right click event wasn't triggered on the correct element and resize was not happening on firefox.
@gkatsev gkatsev mentioned this pull request Nov 11, 2018
@gkatsev gkatsev removed the needs: LGTM Needs one or more additional approvals label Dec 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants