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

UHF-5527 Small accessibility improvements for unit searches and custom searches #902

Merged
merged 14 commits into from
Feb 9, 2024
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
2 changes: 1 addition & 1 deletion dist/css/styles.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/district-and-project-search.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/health-station-search.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/job-search.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/linkedevents.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/maternity-and-child-health-clinic-search.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/news-archive.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/ploughing-schedule.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/school-search.min.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions hdbt.theme
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,15 @@ function _hdbt_preprocess_image_caption(array &$variables, string $entity_type,
}
}

/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function hdbt_theme_suggestions_input_alter(array &$suggestions, array $variables): void {
if (isset($variables['element']['#name'])) {
$suggestions[] = $variables['theme_hook_original'] . '__' . str_replace('-', '_', $variables['element']['#name']);
}
}

/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
Expand All @@ -411,6 +420,10 @@ function hdbt_theme_suggestions_form_element_alter(array &$suggestions, array $v
*/
function hdbt_theme_suggestions_form_alter(array &$suggestions, array $variables): void {
$suggestions[] = 'form__' . str_replace('-', '_', $variables['element']['#id']);

if (isset($variables['element']['unit_search']) && $variables['element']['unit_search']) {
$suggestions[] = 'form__unit_search';
}
}

/**
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

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

Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const FormContainer = () => {
const projectTypeLabel: string = Drupal.t('Project type', {}, { context: 'District and project search form label' });

return (
<form onSubmit={handleSubmit}>
<form onSubmit={handleSubmit} role='search'>
<div className="district-project-search-form__filters-container">
<div className="district-project-search-form__filters">
<TextInput
Expand All @@ -73,6 +73,7 @@ const FormContainer = () => {
placeholder={Drupal.t('For example, Pasila', {}, { context: 'District and project search form label' })}
onChange={handleTitleChange}
value={title}
type='search'
/>
<Combobox
multiselect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const ProximityFormContainer = () => {
};

return (
<form className='hdbt-search--react__form-container' onSubmit={onSubmit}>
<form className='hdbt-search--react__form-container' role='search' onSubmit={onSubmit}>
<TextInput
className='hdbt-search__filter hdbt-search--react__text-field'
helperText={Drupal.t('Enter the street name and house number', {}, { context: 'React search: street input helper'})}
Expand Down
3 changes: 2 additions & 1 deletion src/js/react/apps/job-search/containers/FormContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ const FormContainer = () => {
const languageLabel: string = Drupal.t('Language', {}, { context: 'Language filter label' });

return (
<form className='job-search-form' onSubmit={handleSubmit} action={formAction}>
<form className='job-search-form' role='search' onSubmit={handleSubmit} action={formAction}>
<TextInput
className='job-search-form__filter'
id={SearchComponents.KEYWORD}
label={Drupal.t('Search term', {}, { context: 'Search keyword label' })}
name={SearchComponents.KEYWORD}
type='search'
onChange={handleKeywordChange}
value={keyword}
placeholder={Drupal.t(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function FormContainer() {
}

return (
<form className='hdbt-search--react__form-container' onSubmit={handleSubmit}>
<form className='hdbt-search--react__form-container' role='search' onSubmit={handleSubmit}>
<HeadingTag className='event-list__filter-title'>{Drupal.t('Filter events', {}, { context: 'Event search: search form title' })}</HeadingTag>
<div className='event-form__filters-container'>
<div className='event-form__filter-section-container'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const ProximityFormContainer = () => {
};

return (
<form className='hdbt-search--react__form-container' onSubmit={onSubmit}>
<form className='hdbt-search--react__form-container' role='search' onSubmit={onSubmit}>
<TextInput
className='hdbt-search__filter hdbt-search--react__text-field'
helperText={Drupal.t('Enter the street name and house number', {}, { context: 'React search: street input helper'})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const FormContainer = () => {
return (
<div className='news-form-wrapper'>
<div className='news-form-container'>
<form className='news-form' onSubmit={onSubmit}>
<form className='news-form' role='search' onSubmit={onSubmit}>
<h2>{Drupal.t('Filter news items', {}, {context: 'News archive filter results heading'})}</h2>
<div className='news-form__filters-container'>
{topicOptions && <Filter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const FormContainer = () => {
});

return (
<form className='hdbt-search--react__form-container' onSubmit={onSubmit}>
<form className='hdbt-search--react__form-container' role='search' onSubmit={onSubmit}>
<h2 className='hdbt-search--react__form-title'>
{Drupal.t('See the ploughing schedule', {}, {context: 'Ploughing schedule: Form title / submit'})}
</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const FeatureFormContainer = () => {
const bilingualEducationLabel: string = Drupal.t('Bilingual education', {}, { context: 'TPR Ontologyword details schools' });

return (
<form className='hdbt-search--react__form-container' onSubmit={onSubmit}>
<form className='hdbt-search--react__form-container' role='search' onSubmit={onSubmit}>
<h3>
{Drupal.t('Search with school details', {}, {context: 'School search: Feature form title'})}
</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const ProximityFormContainer = () => {
};

return (
<form className='hdbt-search--react__form-container' onSubmit={onSubmit}>
<form className='hdbt-search--react__form-container' role='search' onSubmit={onSubmit}>
<h3>
{Drupal.t('Search for your local school', {}, {context: 'School search: local search title'})}
</h3>
Expand Down
16 changes: 3 additions & 13 deletions src/scss/06_components/paragraphs/_unit-search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,9 @@
white-space: normal;
}

.hds-text-input__input-wrapper {
&::after {
@include pseudo-icon('search', 20px, $color-black, block);
position: absolute;
right: $spacing;
top: 50%;
transform: translateY(-50%);
}

.hds-text-input__input {
border-radius: 0;
padding-right: $spacing-triple;
}
.hds-text-input__input-wrapper .hds-text-input__input {
border-radius: 0;
padding-right: $spacing-triple;
}

[data-drupal-selector='edit-provided-languages-value'] {
Expand Down
15 changes: 15 additions & 0 deletions templates/form/form--unit-search.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{#
/**
* @file
* Theme override for a 'form' element.
*
* Available variables
* - attributes: A list of HTML attributes for the wrapper element.
* - children: The child elements of the form.
*
* @see template_preprocess_form()
*/
#}
<form{{ attributes.setAttribute('role', 'search') }}>
{{ children }}
</form>
19 changes: 19 additions & 0 deletions templates/form/text-input/input--textfield--unit-search.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{#
/**
* @file
* Theme override for an 'input' #type form element.
*
* Available variables:
* - attributes: A list of HTML attributes for the input element.
* - children: Optional additional rendered elements.
*
* @see template_preprocess_input()
* @see claro_preprocess_input()
*/
#}
{% apply spaceless %}
<div class="hds-text-input__input-wrapper">
<input {{ attributes.setAttribute('type', 'search').addClass('hds-text-input__input') }} />
</div>
{{ children }}
{% endapply %}
Loading