unwanted blur() caused by vivaldi resource inject-root-bundle.js
-
Hello all,
I am building a website, and I have a javascript function triggered by onkeydown, which concludes by using focus() and .select() to select the text inside of an <input> element.
Except it doesn't work as expected.
So using debugger; I stepped through my code, and my code actually does work as expected. However, as soon as my function has completed, some code called "inject-root-bundle.js," which I have determined to be a Vivaldi resource, runs. It appears to also be triggered by a keyboard event handler.
At the end of this piece of code is a blur() that appears to be the culprit that is causing the undesirable behavior.
Does anyone have any insight into how I can prevent this Vivaldi code from interfering with the desired behavior of my code?
P.S. - I did try disabling extensions beforehand and got the same result.
P.P.S - here is the offending code from inject-root-bundle.js as viewed in DevTools:
function x(e) { const t = !(e.ctrlKey || e.altKey || e.metaKey || e.shiftKey) , n = y.activeElement , r = y.scrollingElement , i = e.target.tagName.toUpperCase(); "Space" !== e.code || !t || m.some(e=>location.href.match(e)) || r && !(r.scrollHeight - r.scrollTop - window.innerHeight <= 0) || -1 !== l.indexOf(i) || n && "true" === n.contentEditable || !0 === y.querySelector("[contentEditable]") ? "Escape" === e.key && t && -1 !== s.indexOf(i) && n && n.blur() : (S(), A()) }
-
@jeffbcarter Did you try your code in another browser as well? Just want to make sure it is a Vivaldi issue.
It would also help if you could post a bare bone version of your code, so we can see what exactly you are trying to do.
Edit:
If it does end up being a Vivaldi issue, you might be able to do aremoveEventListener()
since you found the name of the function being called for the listener.
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener -
@nomadic said:
Edit: If it does end up being a Vivaldi issue, you might be able to do a
removeEventListener()
since you found the name of the function being called for the listener.
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListenerNo, they can’t, coz they don’t have access/reference to the function, which is what you actually need.
(see this example)
Assume mouse clicks (2 in total, not 3) before the
log
s happened.
-
@potmeklecbohdan Ah thanks, guess I need to play around with javascript some more.
-
First, thanks for your reply.
OK, so I tried this in both Chrome and Firefox per your suggestion, and I did have the same issue in both of those browsers. Debugging, I found that both of those browsers similarly also had functions with event listeners that were interfering with the desired behavior of my code.
Also, I briefly fiddled around with your removeEventListerner() idea, but when I would call it, the browsers' functions were not yet defined. So I abandoned that idea fairly quickly.
Here's the great news that I'll leave here for posterity: I did scour the interWebs and found a solution...just some setTimeouts fixed it. (I had the timeout set to 0, which worked well in Vivaldi and Chrome, but it turns out Firefox actually needs a slight bit of time to execute its code, so I went with 100ms, and it is acceptable.) Anyway, here's the fix:
window.setTimeout(function () { newElem.focus(); },100); window.setTimeout(function () { newElem.select(); },100);
-
Ppafflick moved this topic from Vivaldi for Windows on