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(snippet): add a snippet widget to be able to highlight snippet results #1797

Merged
merged 1 commit into from
Jan 4, 2017

Conversation

mthuret
Copy link
Contributor

@mthuret mthuret commented Jan 3, 2017

You can now write this: <Snippet attributeName="description" hit={hit}/> and have highlighting for snippet attributes.

#1776

@algobot
Copy link
Contributor

algobot commented Jan 3, 2017

By analyzing the blame information on this pull request, we identified @bobylito, @vvo and @maxiloc to be potential reviewers

Copy link
Contributor

@bobylito bobylito left a comment

Choose a reason for hiding this comment

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

Mostly suggestions (nothing really blocking)

});
return <span className="ais-Highlight">{reactHighlighted}</span>;
export default function Highlight(props) {
return <Highlighter path="_highlightResult" {...props}/>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you notice that path can be overriden?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. The path is not a prop documented in the Highlight/Snippet widget so I figured out it was ok to just forward the props. Do you think it's an issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should be ok 👍

}

Highlight.propTypes = {
Copy link
Contributor

Choose a reason for hiding this comment

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

How come we don't need to add the proptypes in this case?

Copy link
Contributor Author

@mthuret mthuret Jan 4, 2017

Choose a reason for hiding this comment

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

Well if I add them then you get two warnings if a props is missing. From the <Highlight>, and from the <Highlighter>. But I can definitely add them back.

attributeName,
hit,
}) {
if (!hit) throw new Error('`hit`, the matching record, must be provided');

const highlightObject = get(hit._highlightResult, attributeName);
const highlightObject = get(hit[path], attributeName);
Copy link
Contributor

Choose a reason for hiding this comment

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

It's mostly a technicality but here path is not really a path but the property that contains the highlight structure. I suggest we change path to a name that explicitly state that the user can't go deep, idea: highlightProperty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fine with me, I'll change for highlightProperty

@mthuret mthuret force-pushed the feat-snippet branch 2 times, most recently from fe51a4d to 2145b8e Compare January 4, 2017 10:09
@bobylito bobylito merged commit 2aecc40 into v2 Jan 4, 2017
@bobylito bobylito deleted the feat-snippet branch January 4, 2017 15:23
vvo pushed a commit that referenced this pull request Jan 17, 2017
<a name="2.2.0"></a>
# [2.2.0](v2.1.0...v2.2.0) (2017-01-17)

### Bug Fixes

* **clear:** clearing wasn't working with too+ same type facets selected (#1820) ([a9a2364](a9a2364))
* **connectSearchBox:** handle `defaultRefinement` (#1829) ([7a730e2](7a730e2)), closes [#1826](#1826)
* **Instantsearch:** Update all props on InstantSearch (#1828) ([2ed9b49](2ed9b49))
* **InstantSearch:** add specific `react-instantsearch ${version}` agent (#1844) ([a1113bc](a1113bc))
* **SFFV:** correct propTypes and add missing default values (#1845) ([a4c1b31](a4c1b31))
* **test:** add missing Snippet and Highliter snapshot ([4accce5](4accce5))
* **widgets:** replace setImmediate use with Promise use when update is needed (#1811) ([17e2497](17e2497))

### Features

* **Menu, connectMenu:** add search for facet values (#1822) ([a6c513e](a6c513e))
* **snippet:** add a snippet widget to be able to highlight snippet results (#1797) ([2aecc40](2aecc40))
* **widgets:** add transformItems to be able to sort and filter (#1809) ([ba539f0](ba539f0))
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