-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat(vwc-popup): change anchorEl to anchorId #1214
Conversation
🚀 Latest successful build of the PR deployed here. 🚀 |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
this.hide(); | ||
this.anchorEl = this.getAnchorById(); | ||
// For proper positioning, show the popup after a delay when first updated | ||
setTimeout(() => { |
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.
Now I see why you have this delay.
It should be documented in the tests:
it("should delay first position by 300ms")
Or something like that. How did you get to 300ms BTW?
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.
@YonatanKra Having to set timeout, I chose 300 milliseconds because I saw FAST had a 300 millisecond delay for their tooltip to appear.
Would you suggest a time of less than 300 milliseconds?
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.
As I said, we can go with 300ms, it just needs to be documented (in tests) as suggested. Why not 100ms (which is the maximum time for user interaction response)? Would it work then?
I guess 300ms is a heuristic because other factors might delay the page layout calculation (like long running JS or longer running calculations before the component loaded).
So 100ms will not be enough.
By the way, we'd might want to add our own "ready" promise on this component and then use it in the tests. This might be a handy API.
I just don't feel good enough with arbitrary numbers going around.
In either case (arbitrary or not), we need to document this in the tests as this is part of the API exposed to the user (expect the component to finish rendering in 300ms).
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.
Thinking about it, I think we can "hide" this setTimeout
behind an updateComplete
message. Something like that in the firstUpdated
function:
this.updateComplete = new Promise(res => setTimeout(() => {
this.open = this.initialDisplayState;
this.updatePosition();
res();
}, this.DELAY));
I think that's the right syntax. Then the updateComplete
will reflect the 300ms wait.
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.
This way, the 300ms
becomes an implementation details and not an unexpected side effect.
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.
@YonatanKra updateComplete is read-only
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.
Correct me if i'm wrong @rinaok but the denounce is required for document to be ready. The popup component has no way of knowing that
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.
Will this be of any help?
https://toruskit.com/blog/how-to-get-element-bounds-without-reflow/
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.
@YonatanKra updateComplete is read-only
I did something with: _getUpdateComplete
. Might help but seems an overkill.
If 300ms is a must then we need to document it in the tests (e.g. should run positionUpdate on load after 300ms delay
).
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.
@rinaok if the intersection observer solves it, we may wanna create a single intersectionObserver instance and reuse it.
notice it is being used as a service here
https://github.com/microsoft/fast/blob/master/packages/web-components/fast-foundation/src/utilities/intersection-service.ts
we can actually might as well use that service 🤔
Co-authored-by: Yonatan Kra <yonatan.kra@vonage.com>
Co-authored-by: Yonatan Kra <yonatan.kra@vonage.com>
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Find anchor by Id instead of by Element.
Make the popup be open from the start.
Fix some bugs and refactor the code.