Skip to content

Commit

Permalink
Merge pull request #119 from vtex-apps/feature/custom-page-prop
Browse files Browse the repository at this point in the history
add custompage prop
  • Loading branch information
hiagolcm authored Mar 11, 2021
2 parents 8ba1135 + f0b11f6 commit 96d620d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added
- `customPage` prop to the `autocomplete-result-list.v2`.

## [2.5.0] - 2021-02-23

### Added
Expand Down
1 change: 1 addition & 0 deletions docs/Autocomplete.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Add `autocomplete-result-list.v2` into the blocks of a `search-bar`. We also rec
| `customBreakpoints` | [`CustomBreakpointsProp`](#custombreakpointsprop) | Defines a maximum number of suggested products by breakpoints | - |
| `__unstableProductOriginVtex` | `Boolean` | You can use this property as `true` if any of your product-summary props come with a `null` value. This is because some product information does not come by default in the Search. | `false` |
| `simulationBehavior` | `"skip"` or `"default"` | If you want faster searches and do not care about most up to date prices and promotions, use `"skip"` value. | `default` |
| `customPage` | `string` | Defines a custom page to the link of a suggestion. Example: `store.search.custom` | `store.search`

#### ProductLayoutEnum

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "search",
"vendor": "vtex",
"version": "2.5.0",
"version": "2.6.0-beta.0",
"title": "Search",
"description": "Search components and functionality for VTEX IO.",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface ItemListProps {
modifier?: string
onItemHover?: (item: Item | AttributeItem) => void
showTitleOnEmpty?: boolean
customPage?: string
}

interface ItemListState {
Expand Down Expand Up @@ -77,7 +78,10 @@ export class ItemList extends React.Component<ItemListProps> {
onBlur={() => this.handleMouseOut()}
>
<Link
to={item.link}
page={this.props.customPage ?? 'store.search'}
params={{
term: item.value,
}}
query="map=ft"
onClick={() => this.props.onItemClick(item.value, index)}
className={stylesCss.itemListLink}
Expand Down
4 changes: 4 additions & 0 deletions react/components/Autocomplete/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ interface AutoCompleteProps {
product: Product
actionOnClick: () => void
}>
customPage?: string
}

interface AutoCompleteState {
Expand Down Expand Up @@ -414,6 +415,7 @@ class AutoComplete extends React.Component<
this.props.runtime.page,
EventType.SearchSuggestionClick
)}
customPage={this.props.customPage}
/>
)
}
Expand All @@ -439,6 +441,7 @@ class AutoComplete extends React.Component<
this.props.runtime.page,
EventType.TopSearchClick
)}
customPage={this.props.customPage}
/>
) : null}

Expand All @@ -454,6 +457,7 @@ class AutoComplete extends React.Component<
this.props.runtime.page,
EventType.HistoryClick
)}
customPage={this.props.customPage}
/>
) : null}
</div>
Expand Down

0 comments on commit 96d620d

Please sign in to comment.