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-7410: Language related accessibility fixes for job listings and job search #217

Merged
merged 3 commits into from
Mar 21, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,23 @@ function helfi_rekry_content_preprocess_field(&$variables) {

// Expose original language to field templates.
$variables['original_language'] = $originalLanguage;
$inlineFields = [
'title',
'field_salary',
];

// Use span instead of div for inline fields.
if (isset($variables['field_name']) && in_array($variables['field_name'], $inlineFields)) {
$variables['original_language_inline'] = TRUE;
}

// Expose original language as an attribute for these fields.
$wrappedFields = [
'field_salary_class',
'field_organization_name',
];

if ($variables['field_name'] && in_array($variables['field_name'], $wrappedFields)) {
if (isset($variables['field_name']) && in_array($variables['field_name'], $wrappedFields)) {
foreach ($variables['items'] as $item) {
$item['attributes']->setAttribute('lang', 'fi');
}
Expand Down

This file was deleted.

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions public/modules/custom/helfi_rekry_job_search/assets/main.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ const ResultCard = ({

let heading = title[0];

let jobs_amount = null;
if (field_jobs[0] > 1) {
heading += ` (${field_jobs} ${Drupal.t('jobs')})`;
jobs_amount = ` (${field_jobs} ${Drupal.t('jobs')})`;
}

const customAtts: HTMLAttributes<HTMLHeadingElement | HTMLDivElement> = {};

if (field_copied?.length && field_original_language?.length) {
customAtts.lang = field_original_language[0];
}
Expand All @@ -41,9 +41,10 @@ const ResultCard = ({

return (
<div role='article' className='node--type-job-listing node--view-mode-teaser'>
<h3 className='job-listing__title' {...customAtts}>
<h3 className='job-listing__title'>
<a href={url[0]} rel='bookmark'>
{heading.charAt(0).toUpperCase() + heading.slice(1)}
<span {...customAtts}>{heading.charAt(0).toUpperCase() + heading.slice(1)}</span>
{jobs_amount && <span>{jobs_amount}</span>}
</a>
</h3>
<section
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
{# Set lang attributes if needed #}
{% if original_language_inline %}
{% set original_language_wrapper = 'span' %}
{% else %}
{% set original_language_wrapper = 'div' %}
{% endif %}
{% set content %}
{% if original_language %}
<div lang="{{ original_language }}">
<{{original_language_wrapper}} lang="{{ original_language }}">
{% endif %}

{% for item in items %}
{{ item.content }}
{% endfor %}

{% if original_language %}
</div>
</{{original_language_wrapper}}>
{% endif %}
{% endset %}

Expand Down