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

feat(vwc-popup): change anchorEl to anchorId #1214

Merged
merged 24 commits into from
Feb 7, 2022
Merged

Conversation

rinaok
Copy link
Contributor

@rinaok rinaok commented Jan 25, 2022

Find anchor by Id instead of by Element.
Make the popup be open from the start.
Fix some bugs and refactor the code.

@github-actions
Copy link

🚀

Latest successful build of the PR deployed here.

🚀

@rinaok rinaok changed the title change anchor to id feat(vwc-popup): change anchor to id Jan 25, 2022
@rinaok rinaok linked an issue Jan 25, 2022 that may be closed by this pull request
@rinaok rinaok self-assigned this Jan 25, 2022
components/popup/src/vwc-popup-base.ts Outdated Show resolved Hide resolved
components/popup/src/vwc-popup-base.ts Outdated Show resolved Hide resolved
components/popup/src/vwc-popup-base.ts Outdated Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Jan 26, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@rinaok rinaok marked this pull request as ready for review January 26, 2022 16:21
@rinaok rinaok changed the title feat(vwc-popup): change anchor to id feat(vwc-popup): change anchorEl to anchorId Jan 26, 2022
components/popup/src/vwc-popup-base.ts Outdated Show resolved Hide resolved
components/popup/src/vwc-popup-base.ts Outdated Show resolved Hide resolved
components/popup/test/popup.test.js Show resolved Hide resolved
@yinonov yinonov added the Type: Component 🛠 Assigned to PRs delivering brand-new components to the Vivid catalog label Jan 26, 2022
@rinaok rinaok requested a review from yinonov January 27, 2022 10:46
this.hide();
this.anchorEl = this.getAnchorById();
// For proper positioning, show the popup after a delay when first updated
setTimeout(() => {
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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).

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

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).

Copy link
Contributor

@yinonov yinonov Jan 30, 2022

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 🤔

@sonarcloud
Copy link

sonarcloud bot commented Feb 7, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@rinaok rinaok merged commit c7640bd into master Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Component 🛠 Assigned to PRs delivering brand-new components to the Vivid catalog
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[popup]: anchor value
3 participants