Skip to content

Commit 965a113

Browse files
committed
feat(searchbox): allow customising the title attributes (WIP)
PR still marked as WIP as I'm not sure if this is the right long-term solution, and haven't updated the tests yet.
1 parent 2f9b3ea commit 965a113

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

packages/instantsearch.js/src/components/SearchBox/SearchBox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class SearchBox extends Component<
207207
rootProps={{
208208
className: cssClasses.submit,
209209
type: 'submit',
210-
title: 'Submit the search query',
210+
title: templates.submitTitle,
211211
hidden: !showSubmit,
212212
}}
213213
templates={templates}
@@ -220,7 +220,7 @@ class SearchBox extends Component<
220220
rootProps={{
221221
className: cssClasses.reset,
222222
type: 'reset',
223-
title: 'Clear the search query',
223+
title: templates.resetTitle,
224224
hidden: !(
225225
showReset &&
226226
this.state.query.trim() &&

packages/instantsearch.js/src/widgets/search-box/defaultTemplates.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const defaultTemplate: SearchBoxComponentTemplates = {
1717
</svg>
1818
);
1919
},
20+
resetTitle: 'Clear the search query',
2021
submit({ cssClasses }) {
2122
return (
2223
<svg
@@ -30,6 +31,7 @@ const defaultTemplate: SearchBoxComponentTemplates = {
3031
</svg>
3132
);
3233
},
34+
submitTitle: 'Submit the search query',
3335
loadingIndicator({ cssClasses }) {
3436
/* eslint-disable react/no-unknown-property */
3537
// Preact supports kebab case attributes, and using camel case would

packages/instantsearch.js/src/widgets/search-box/search-box.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,18 @@ export type SearchBoxTemplates = Partial<{
3232
* Template used for displaying the submit button. Can accept a function or a Hogan string.
3333
*/
3434
submit: Template<{ cssClasses: SearchBoxComponentCSSClasses }>;
35+
/**
36+
* Template used for alternative text for the submit button icon. Only accepts a string.
37+
*/
38+
submitTitle: string;
3539
/**
3640
* Template used for displaying the reset button. Can accept a function or a Hogan string.
3741
*/
3842
reset: Template<{ cssClasses: SearchBoxComponentCSSClasses }>;
43+
/**
44+
* Template used for alternative text for the reset button icon. Only accepts a string.
45+
*/
46+
resetTitle: string;
3947
/**
4048
* Template used for displaying the loading indicator. Can accept a function or a Hogan string.
4149
*/

0 commit comments

Comments
 (0)