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

Make it possible for the site search input field to have different values for "name" and ID #688

Merged
merged 1 commit into from
Jun 3, 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
8 changes: 6 additions & 2 deletions core/src/templates/components/site-search/site-search.twig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
* - action: Action of the form
* - method: Method of the form
* - search_label: Custom screen reader label
* - search_input_name: Name for the search input field. Also used as the ID of the search input field and the "for" attribute of the label.
* - search_input_name: Name for the search input field. Also used as the "for" attribute of the search input field label.
* - search_input_id: ID for the search input field. If not provided, it will take on the same value as search_input_name.
* - search_input_attributes: Additional HTML attributes for the search input field
* - placeholder: Placeholder text for the search input field
* - search_button_attributes: Additional HTML attributes for the submit button
Expand All @@ -21,10 +22,13 @@
*
*/
#}
{%- if search_input_id is empty -%}
{%- set search_input_id = search_input_name -%}
{%- endif -%}
Comment on lines +25 to +27
Copy link
Member

Choose a reason for hiding this comment

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

This keeps it backwards compatible but we should remove it in version 7 and just go with the two separate ids.

<div {{ attributes }} class="su-site-search {{ modifier_class }}" role="search">
<form action="{{ action }}" method="{{ method }}" accept-charset="UTF-8">
<label class="su-site-search__sr-label" for="{{ search_input_name|default('search-field') }}">{{ search_label|default('Search this site') }}</label>
<input {{ search_input_attributes }} type="text" id="{{ search_input_name|default('search-field') }}" name="{{ search_input_name|default('search-field') }}" class="su-site-search__input" placeholder="{{ placeholder|default('Search this site') }}" maxlength="128">
<input {{ search_input_attributes }} type="text" id="{{ search_input_id|default('search-field') }}" name="{{ search_input_name|default('search-field') }}" class="su-site-search__input" placeholder="{{ placeholder|default('Search this site') }}" maxlength="128">
<button {{ search_button_attributes }} type="submit" name="{{ search_button_name|default('search') }}" class="su-site-search__submit su-sr-only-text" aria-label="Search">{{ search_button_text|default('Submit Search') }}</button>
{#- Any additional eg. hidden input fields -#}
{{- additional_fields -}}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.