-
Notifications
You must be signed in to change notification settings - Fork 104
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
site: fix firefox bug #1811
site: fix firefox bug #1811
Conversation
This only happens on master, not release-v0.5, so it seems clear it's the recent wallet page restyling, but I don't understand why. There doesn't seem to be any difference with |
I'm going to investigate too, but @buck54321 your input is probably needed to discern why this is a problem on master but not |
It's actually because firefox fires a static mouseInElement (e: MouseEvent, el: HTMLElement): boolean {
if (e.target && (e.target as HTMLElement).tagName === 'OPTION') return true
...
Before re-styling, I don't think we were hiding the form when you clicked outside. It wasn't a modal dialog. |
So I guess this behaviour only affects the |
In my tests, it was the option element that had the zeroed coordinates. Please do verify. |
Yes, I can verify. That was why I added this line. @buck54321, can we have this check with your suggestion? zeroed coordinates could come from somewhere else.
|
a8d4403
to
107e914
Compare
client/webserver/site/src/js/doc.ts
Outdated
static mouseInElement (e: MouseEvent, el: HTMLElement): boolean { | ||
if (e.target && (e.target as HTMLElement).tagName === 'OPTION') return true | ||
const rect = el.getBoundingClientRect() | ||
return e.pageX >= rect.left && e.pageX <= rect.right && | ||
e.pageY >= rect.top && e.pageY <= rect.bottom |
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.
Seems like we're overthinking this.
static mouseInElement (e: MouseEvent, el: HTMLElement): boolean {
return el.contains(e.target as Node)
}
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.
Nice find. That should work, with a couple of caveats.
- You probably need to check if the target is the element itself, otherwise that click padding would become ineffective. Something like
return el === e.target || el.contains(e.target as Node)
- This would fail if we had an element that's not a descendant absolutely positioned over the form. I'm not sure that we do that with anything but tooltips, so it probably won't matter to us.
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.
- You probably need to check if the target is the element itself, otherwise that click padding would become ineffective. Something like
https://developer.mozilla.org/en-US/docs/Web/API/Node/contains
contains
covers self, apparently:
The contains() method of the Node interface returns a boolean value indicating whether a node is a descendant of a given node, that is the node itself, one of its direct children (childNodes), one of the children's direct children, and so on.
Note: A node is contained inside itself.
It also doesn't seem to be related to position, just DOM hierarchy.
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.
contains covers self, apparently
yeah, your suggestion is efficient.
107e914
to
ae5262d
Compare
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.
Can confirm the bug and this fixes it.
I investigated the issue resulting in #1808 and found out firefox and chrome behave differently on
mousedown
events.I think the issue lies in the fact that Firefox triggers 3 events (onmousedown, onmousedown, onchange) instead of 2 (onmousedown, onchange) like Chrome does. The last
onmousedown
will have the screen coordination value of the event set to zero(cause the last mouseevent
is actually right in theElement
?). Closes #1808.Reference 1: w3c uievents #201