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

Fixes for search examples #2081

Merged
merged 2 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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