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

Add data attributes to FacetItem component #694

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Changed

- Add attributes to the checkbox component to be able to collect data through activity flow

## [3.136.0] - 2025-01-16

### Added
Expand Down
19 changes: 18 additions & 1 deletion react/components/FacetItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { useSearchPage } from 'vtex.search-page-context/SearchPageContext'
import { usePixel } from 'vtex.pixel-manager'
import { useIntl } from 'react-intl'
import { useRuntime } from 'vtex.render-runtime'

import { pushFilterManipulationPixelEvent } from '../utils/filterManipulationPixelEvents'
import SettingsContext from './SettingsContext'
Expand Down Expand Up @@ -125,6 +126,17 @@
intl,
])

const runtimeQuery = useRuntime()?.query

let initialmap
let initialquery

if (searchQuery?.variables?.fullText === undefined) {
initialquery = runtimeQuery?.initialQuery ?? searchQuery?.facets?.queryArgs.query

Check failure on line 135 in react/components/FacetItem.js

View workflow job for this annotation

GitHub Actions / Lint

Insert `⏎·····`

Check failure on line 136 in react/components/FacetItem.js

View workflow job for this annotation

GitHub Actions / Lint

Delete `····`
initialmap = runtimeQuery?.initialMap ?? searchQuery?.facets?.queryArgs?.map
}

return (
<div
className={classes}
Expand All @@ -148,8 +160,13 @@
setSelected(!selected)
navigateToFacet({ ...facet, title: facetTitle }, preventRouteChange)
}}
value={facet.name}
disabled={shouldDisable}
value={facet.value}
facetKey={facet.key}
isClicked={selected.toString()}
fullText={searchQuery?.variables?.fullText}
initialMap={initialmap}
initialQuery={initialquery}
/>
</div>
)
Expand Down
Loading