-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Make right-click work on all browsers #342
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
Conversation
src/utils/Generic.js
Outdated
| * @module xterm/utils/Generic | ||
| */ | ||
|
|
||
| export let contains = function(el, arr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arr, el would be more intuitive ordering imo "does arr contain el"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 changing
src/utils/Generic.js
Outdated
| */ | ||
|
|
||
| export let contains = function(el, arr) { | ||
| for (var i = 0; i < arr.length; i += 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return arr.indexOf(el) >= 0;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 changing
src/xterm.js
Outdated
| }); | ||
| } | ||
|
|
||
| if (isFirefox || isMSIE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a concern you're forking the logic here? If both work equally well with mousedown maybe that would be better so all browsers use the same code path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it doesn't work on Chrome with mousedown. The "Paste" option is disabled.
| term.textarea.style.height = '10px'; | ||
| term.textarea.style.left = x + 'px'; | ||
| term.textarea.style.top = y + 'px'; | ||
| term.textarea.style.width = '20px'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why this is bigger all of a sudden?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just gave it a little bit of padding, because I think it could run into corner cases.
|
@Tyriar do you have any clue why this particular test might be failing? |
|
@parisk probably related to |
|
Thanks @Tyriar, the error message wasn't that helpful 😅 . I was setting |
|
@Tyriar tests are passing, feel free to take another look, when it's 🆗 for you. |
Made right-click work on all browsers.
The issue with the previous implementation was that it was bound to the
contextmenuDOM event.While this works for Chrome and Safari (and Edge?), Firefox and Internet Explorer fire the
contextmenuevent after the menu appears (thus highjacking the textarea position is pointless). So, I moved on and detected right-click using themousedownDOM event on Firefox and MSIE.In addition, I moved all browser detecting utilities into a new
utils/Browser.jsmodule.I would like to add some tests for this module but I couldn't find a way to make it work with Mocha, since
navigatoris absent.Closes #310