Skip to content
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
6 changes: 6 additions & 0 deletions assets/js/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const getTranslation = (fullName) => {
parent.classList.add('hds-text-input--invalid');
const errorSpan = document.createElement('span');
errorSpan.classList.add('hds-text-input__error-text');
errorSpan.id = 'js-locate-error';
errorSpan.textContent = Drupal.t(
"We couldn't retrieve your current location. Try entering an address.",
{},
Expand Down Expand Up @@ -229,6 +230,11 @@ const getTranslation = (fullName) => {
});
// Hide location error input when changing input
element.addEventListener('change', removeLocationError);

// Focus input if there is a validation error on page load.
if (element.classList.contains('error')) {
element.focus();
}
};

Drupal.behaviors.helfi_location_autocomplete = {
Expand Down
2 changes: 1 addition & 1 deletion dist/js/autocomplete.min.js

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

9 changes: 9 additions & 0 deletions helfi_platform_config.module
Original file line number Diff line number Diff line change
Expand Up @@ -502,3 +502,12 @@ function helfi_platform_config_preprocess_page(array &$variables) : void {
$variables['#attached']['library'][] = 'helfi_platform_config/heading_anchor_buttons';
}
}

/**
* Implements hook_preprocess_HOOK().
*/
function helfi_platform_config_preprocess_form_element__helfi_location_autocomplete(array &$variables):void {
if (isset($variables['element']['#errors']) && empty($variables['errors'])) {
$variables['errors'] = $variables['element']['#errors'];
}
}
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ parameters:
count: 1
path: helfi_platform_config.module

-
message: "#^Function helfi_platform_config_preprocess_form_element__helfi_location_autocomplete\\(\\) has parameter \\$variables with no value type specified in iterable type array\\.$#"
count: 1
path: helfi_platform_config.module

-
message: "#^Function helfi_platform_config_preprocess_html\\(\\) has parameter \\$variables with no type specified\\.$#"
count: 1
Expand Down
Loading