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(components): new component to wrap components so a display event is emitted when they appear in the viewport for the first time #1391

Merged

Conversation

CachedaCodes
Copy link
Contributor

@CachedaCodes CachedaCodes commented Jan 9, 2024

EMP-3241

Motivation and context

We needed a way of emitting a display event when a specific component appeared in the viewport. This PR adds a new component that will do that with any component that is passed as slot.

  • Dependencies. If any, specify:
  • Open issue. If applicable, link:

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that causes existing functionality to not work as expected)
  • Change requires a documentation update

What is the destination branch of this PR?

How has this been tested?

The query previews in the home component are wrapped by the new component. Test it by checking if a display event is emitted when they appear in the viewport.

@CachedaCodes CachedaCodes requested a review from a team as a code owner January 9, 2024 13:10
@diegopf diegopf self-requested a review January 15, 2024 12:23
Base automatically changed from feature/EMP-3241-display-tagging-in-query-preview to main January 15, 2024 16:13
const { isElementVisible, unwatchDisplay } = useOnDisplay({
element,
callback: callbackSpy,
...(!triggerOnce && { triggerOnce })
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
...(!triggerOnce && { triggerOnce })
triggerOnce

what am I missing here? why do all that?😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So If I send null it doesn't send anything to the method, which doesn't make sense because I have true by default, so I'm actually not testing if the composable sets triggerOnce = true by default because I was doing it manually in this function.

…is-visible

# Conflicts:
#	packages/x-adapter-platform/src/mappers/responses/__tests__/__snapshots__/search-response.mapper.spec.ts.snap
@CachedaCodes CachedaCodes requested a review from a team as a code owner January 19, 2024 09:00
Copy link
Contributor

@herrardo herrardo left a comment

Choose a reason for hiding this comment

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

The open source community was waiting this for a long time, great job!

@CachedaCodes CachedaCodes merged commit c463352 into main Jan 25, 2024
4 checks passed
@CachedaCodes CachedaCodes deleted the feature/EMP-3243-emit-events-when-component-is-visible branch January 25, 2024 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants