-
Notifications
You must be signed in to change notification settings - Fork 34
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
fix(atomic): using _blank
target on custom recommendation link template opens two tabs on click
#4953
Conversation
Pull Request ReportPR Title✅ Title follows the conventional commit spec. Live demo linksBundle Size
SSR Progress
Detailed logssearch : buildInteractiveResultsearch : buildInteractiveInstantResult search : buildInteractiveRecentResult search : buildInteractiveCitation search : buildGeneratedAnswer recommendation : missing SSR support case-assist : missing SSR support insight : missing SSR support commerce : missing SSR support |
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.
I certainly wouldn't find anything more clever myself.
But i'm always sad about adding obscure stopPropagation
with sometime very obscure purpose.
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.
While doing some checks, I think about 2w ago; I noticed some behaviour was not OK overall with the link slot.
Overall, the feature is supposed to work as such:
When an atomic-[result|product]-link
is provided into a slot=link
template, it should be used for any click occurring anywhere on the rendered item, notwithstanding the anchor tag and other clickable that do handle the click first (and include a stopPropagation).
I do not think we narrowed down the root cause of this issue, and I think the feature might be broken. If that's the case, I think it'd be best to send back the ticket to @coveo/search team so that we can do a holistic and comprehensive fix on this one.
packages/atomic/src/components/recommendations/atomic-recs-list/e2e/atomic-recs-list.e2e.ts
Outdated
Show resolved
Hide resolved
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.
I tested and the issue is also reproducible in the atomic-commerce-recommendation-list component.
Would you mind fixing it as well (and adjusting the tests), @lbergeron ?
Thanks for the pointer, will look into it. |
On that one, I was off the mark. forget about it 😅 |
SVCC-4611
When a recommendation list uses a custom link template to open recommendations in a new tab, clicking the recommendation opens two tabs instead of one.
How to reproduce the issue
atomic-recs-result-template
as per documentation.Problem
The recommendation list components rely on DisplayGrid for their rendering. The problem is related to this line where
DisplayGrid
forces a click on the recommendation content. When the recommendation content overrides thelink
slot, it already has an event handler for theclick
. It means that, when clicking the recommendation content, itsclick
handler is invoked (opening the first tab). Then, the event propagates to the parent (DisplayGrid
) which forces aclick
event on the content, causing another tab to open.Proposed solution
The proposed solution is to modify the recommendation lists to detect whether the
link
slot is modified. If it is, then thestopPropagation
property is set on the childatomic-recs-result
component. It prevents theclick
event from being propagated to the parent when clicking a recommendation content. However, when outside the recommendation content (i.e., the margin),DisplayGrid
still forces theclick
on the content, opening a single tab.