Skip to content

Commit

Permalink
Merge pull request #2081 from thostetler/fix-search-examples
Browse files Browse the repository at this point in the history
Fixes for search examples
  • Loading branch information
ehenneken committed Nov 19, 2020
2 parents 2ef87f4 + a40a0f9 commit d53e5e7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
22 changes: 18 additions & 4 deletions src/js/react/Recommender/components/SearchExamples.jsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ define([
<React.Fragment>
<dt>{label}</dt>
<dd>
<button type="button" onClick={onClick} className="text-link">
<button
type="button"
onClick={onClick}
className="text-link"
style={{ border: 'dotted 1px rgba(0,0,0,0.3)', marginRight: '4px' }}
>
{text}
</button>
{tooltip && (
Expand Down Expand Up @@ -62,27 +67,36 @@ define([
};

return (
<div style={{ paddingTop: '1rem' }}>
<div className="col-sm-5 quick-reference">
<div
style={{
paddingTop: '1rem',
display: 'flex',
justifyContent: 'space-between',
flexWrap: 'wrap',
}}
>
<div className="quick-reference">
<Dl>
{searchExamples.slice(0, 7).map((entry) => (
<Entry
label={entry.label}
text={entry.example}
tooltip={entry.tooltip}
onClick={() => onClick(entry.example)}
key={entry.label}
/>
))}
</Dl>
</div>
<div className="col-sm-7 quick-reference">
<div className="quick-reference">
<Dl>
{searchExamples.slice(7).map((entry) => (
<Entry
label={entry.label}
text={entry.example}
tooltip={entry.tooltip}
onClick={() => onClick(entry.example)}
key={entry.label}
/>
))}
</Dl>
Expand Down
16 changes: 6 additions & 10 deletions src/js/widgets/search_bar/search_bar_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,16 +344,6 @@ define([
});

this.$('[data-toggle="tooltip"]').tooltip();

// this is for search examples, sets form value on click
this.$('.search-quick-links button').on('click', (e) => {
const value = e.currentTarget.innerText.trim();

if (value) {
this.setFormVal(`${this.getFormVal()} ${value}`);
this.$input.focus();
}
});
},

events: {
Expand Down Expand Up @@ -772,6 +762,12 @@ define([
$input.select();
$(document.documentElement).scrollTop(0);
}
} else if (event === 'recommender/update-search-text') {
const value = arg.text;
if (value) {
this.view.setFormVal(`${this.view.getFormVal()} ${value}`);
this.view.$input.focus();
}
}
},

Expand Down

0 comments on commit d53e5e7

Please sign in to comment.