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(search): surface explorer views in search results #3429

Merged

Conversation

marcelgerber
Copy link
Member

@marcelgerber marcelgerber commented Mar 29, 2024

TODOs

  • Implement card-based design
  • Do grouping by explorerSlug
  • Do client-side deduplication based on [viewTitle, explorerSlug]
  • Add click tracking
  • maybe do country name removal (optionalWords)
  • probably sort explorer cards with more view items higher up
  • cleanup:

@marcelgerber marcelgerber changed the title feat(search): surface explorer views in autocomplete feat(search): surface explorer views in search results Mar 29, 2024
@marcelgerber marcelgerber force-pushed the search-explorer-indexing-algolia branch from 3c15ba9 to 5a1a957 Compare March 29, 2024 11:32
@marcelgerber marcelgerber force-pushed the search-explorer-indexing branch from 945fe68 to a949af3 Compare April 2, 2024 11:31
@marcelgerber marcelgerber force-pushed the search-explorer-indexing-algolia branch 3 times, most recently from 26c8f28 to 539259b Compare April 2, 2024 12:27
@marcelgerber marcelgerber force-pushed the search-explorer-indexing branch from 546e78c to f988fdc Compare April 9, 2024 12:05
@marcelgerber marcelgerber force-pushed the search-explorer-indexing-algolia branch 2 times, most recently from 4af8522 to 37806f4 Compare April 9, 2024 12:21
@marcelgerber marcelgerber force-pushed the search-explorer-indexing branch from d2dffb9 to 7dbbc49 Compare April 10, 2024 11:03
@marcelgerber marcelgerber force-pushed the search-explorer-indexing-algolia branch from 6ace3db to a888e19 Compare April 10, 2024 11:03
@marcelgerber
Copy link
Member Author

Click tracking is now part of this, but it's a bit messy overall:

For posts (unchanged)

{
	query: "co2",
	position: 2, // Second overall entry
	positionInSection: 2,
	filter: "all"
}

For charts (unchanged)

{
	query: "co2",
	position: 6, // Second chart, 6th global result
	positionInSection: 2,
	filter: "all"
}

For full explorer links ("Explore all ... indicators")

{
	query: "co2",
	position: 9, // First explorer card
	positionInSection: 1,
	cardPosition: 1,
	positionWithinCard: 0, // Special marker for the "Explore all ..." link
	filter: "all"
}

For links to a view

{
	query: "co2",
	position: 14, // Second explorer card, second link
	positionInSection: 6, // Five results (links) before
	cardPosition: 2, // Card number 2
	positionWithinCard: 2,
	filter: "all"
}

Of course, the href is also always included as an eventTarget property.

Am I happy with that? Not really 🤷🏻
If anyone can come up with a better and more straightforward way then please let me know!!

@marcelgerber marcelgerber marked this pull request as ready for review April 10, 2024 12:58
@marcelgerber marcelgerber requested a review from ikesau April 10, 2024 12:58
Base automatically changed from search-explorer-indexing to master April 11, 2024 15:06
@marcelgerber marcelgerber force-pushed the search-explorer-indexing-algolia branch from 31341e3 to 4927798 Compare April 11, 2024 16:06
@marcelgerber marcelgerber changed the base branch from master to search-pages-disable-fulltext-country-detection April 11, 2024 16:06
@marcelgerber marcelgerber force-pushed the search-pages-disable-fulltext-country-detection branch from cb9fc63 to 67583c5 Compare April 11, 2024 16:22
@marcelgerber marcelgerber force-pushed the search-explorer-indexing-algolia branch from 4927798 to ca8196c Compare April 11, 2024 16:22
Copy link
Member

@ikesau ikesau left a comment

Choose a reason for hiding this comment

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

The functionality is overall very nice! Just a few comments on behind the scenes stuff

highlightedTagName="strong"
className="search-results__explorer-view-title"
/>
<FontAwesomeIcon icon={faArrowRight} />
Copy link
Member

Choose a reason for hiding this comment

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

You might want to position: absolute; margin-top: .5rem this so that it doesn't dangle

Copy link
Member

Choose a reason for hiding this comment

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

With display: block; width: calc(100% - 16px); on .search-results__explorer-view-title-container to ensure there's space

Copy link
Member Author

Choose a reason for hiding this comment

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

Could achieve the same thing using &zwj; (zero-width joiner) and white-space: nowrap.
PR will go up soon, together with other design changes.

site/search/SearchPanel.tsx Show resolved Hide resolved
@@ -128,17 +136,152 @@ function ChartHit({ hit }: { hit: IChartHit }) {
)
}

function ExplorerHit({ hit }: { hit: IExplorerHit }) {
interface ExplorerViewHitWithPosition extends IExplorerViewHit {
Copy link
Member

Choose a reason for hiding this comment

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

I think this is a regression not from this PR, but it seems like data-algolia-position is now only local to each section, i.e. posts start at 1, charts start at 1, etc.

charts were meant to start at numberOfPosts + 1

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that's what it was meant to do, right?
data-algolia-position is the local position, and globalPosition gets computed in the click handler on its own (and only gets sent to GTM, not to Algolia).

@marcelgerber marcelgerber force-pushed the search-pages-disable-fulltext-country-detection branch 2 times, most recently from f54369b to c1520b0 Compare April 11, 2024 21:14
@marcelgerber marcelgerber force-pushed the search-pages-disable-fulltext-country-detection branch from c1520b0 to f9eb694 Compare April 15, 2024 10:14
@marcelgerber marcelgerber force-pushed the search-explorer-indexing-algolia branch from ca8196c to d46ddf7 Compare April 15, 2024 10:14
@marcelgerber marcelgerber force-pushed the search-explorer-indexing-algolia branch from d46ddf7 to d9dc7b2 Compare April 15, 2024 11:21
Base automatically changed from search-pages-disable-fulltext-country-detection to master April 15, 2024 14:38
@marcelgerber marcelgerber changed the base branch from master to search-feature-branch-2024-2 April 16, 2024 06:53
@marcelgerber marcelgerber merged commit 6be2870 into search-feature-branch-2024-2 Apr 16, 2024
21 of 24 checks passed
@marcelgerber marcelgerber deleted the search-explorer-indexing-algolia branch April 16, 2024 06:56
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.

2 participants