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

bug(Datepicker): Hidden calendar button not in the selected language #25021

Closed
1 task
JaDub3 opened this issue Jun 3, 2022 · 18 comments · Fixed by #26738
Closed
1 task

bug(Datepicker): Hidden calendar button not in the selected language #25021

JaDub3 opened this issue Jun 3, 2022 · 18 comments · Fixed by #26738
Assignees
Labels
area: material/datepicker docs This issue is related to documentation good first issue This issue is a good place to start for first time contributors to the project P4 A relatively minor issue that is not relevant to core functions

Comments

@JaDub3
Copy link

JaDub3 commented Jun 3, 2022

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

Description

When the locale changes for the datepicker, the calendar switch to the appropriate language. But the hidden 'Close calendar' button stay in english. This is an issue for accessibility, especially for reader application.

image

Reproduction

Steps to reproduce:

  1. Change locale to French
  2. Open the Datepicker
  3. Press 'TAB' until the hidden button appear

Expected Behavior

The label and content of the button should be in the language specified by the locale.

Actual Behavior

The hidden button stay in english

Environment

  • Angular: 11+
  • CDK/Material: Datepicker
  • Browser(s): Chrome, Firefox
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows
@JaDub3 JaDub3 added the needs triage This issue needs to be triaged by the team label Jun 3, 2022
@zarend
Copy link
Contributor

zarend commented Jun 10, 2022

Since the Close calendar string comes from the MatDatepickerIntl and is not hard-coded, this seems to be an issue with the demo, rather than the date picker itself.

@zarend zarend added P4 A relatively minor issue that is not relevant to core functions docs This issue is related to documentation area: material/datepicker and removed needs triage This issue needs to be triaged by the team labels Jun 10, 2022
@JaDub3
Copy link
Author

JaDub3 commented Jun 10, 2022 via email

@zarend
Copy link
Contributor

zarend commented Jun 17, 2022

This demo needs to implement proving a different value for MatDatepickerIntl because that is where the "Close calendar" string comes from. Here are roughly the steps that need to happen to implement this in the demo.

  1. extend MatDatepickerIntl with French strings
class MatDatepickerIntlFr extends MatDatepickerIntl {
   closeCalendar: "
Fermer le calendrier"
  // ...
}
  1. Inject MatDatepickerIntl into the example.
  2. When clicking "Dynamically switch to French", inject MatDatepickerIntlFr instead

Community contributions are welcome :).

If your code only needs french and doesn't need English, you can provide MatDatepickerIntlFr in your code. there would be no need to change it dynmically. The code would look something like:

provide: MatDatepickerIntl, useClass: MatDatepickerIntlFr

@zarend zarend added the good first issue This issue is a good place to start for first time contributors to the project label Jun 17, 2022
@JaDub3
Copy link
Author

JaDub3 commented Jun 17, 2022 via email

@zarend
Copy link
Contributor

zarend commented Jun 17, 2022

I believe this should be doable with a factory provider. Provide the locale as a dependency to the factory provider. The factory returns an instance of either MatDatepickerIntl or MatDatepickerIntlFr depending on what the locale is.

@maykonpacheco
Copy link

I will try solve.

@GKosheev
Copy link

Hey @maykonpacheco, are you still working on that issue?

@maykonpacheco
Copy link

@GKosheev yes, do you have any suggestion?

@AncelHernandez
Copy link

Talked though this with @amysorto , will be improving the example.

@AncelHernandez
Copy link

Just an update on this, seems like there needs to be changes done on the to the datepicker-base.ts file. When locale updates happen, the class does not re-evaluate the value of the close calendar button. I think moving the initialization of the _closeButtonText value from the constructor to ngOnInit would solve this issue since it would reevaluate every time the calendar content is rendered. But maybe we could listen in to the intl.changes observable and evaluate those values when that emits.

@amysorto
Copy link
Contributor

amysorto commented Sep 2, 2022

You can do intl.changes.next() after changing the value of the close button text so that the service knows something needs to be updated (MatDatepickerIntl docs).

@Gua00va
Copy link

Gua00va commented Feb 15, 2023

Is this issue still open? I would like to work on this.

@zarend
Copy link
Contributor

zarend commented Feb 16, 2023

Hello @Gua00va ,

I believe this issue is still open, and you are welcome to work on it.

-Zach

hamzajazyri added a commit to hamzajazyri/components that referenced this issue Feb 18, 2023
…d up in lazy-loaded modules

Along the same lines as angular#12934, where the consumer-provided  instance was not being picked up within lazy-loaded modules. The fix also resolves an issue with the close button text when switching to French language in components-examples.

fixes angular#25021
hamzajazyri added a commit to hamzajazyri/components that referenced this issue Feb 18, 2023
…ing picked up in lazy-loaded modules

Along the same lines as angular#12934, where the consumer-provided instance was not being picked up within lazy-loaded modules. The fix also resolves an issue with the close button text when switching to French language in components-examples.

fixes angular#25021
hamzajazyri added a commit to hamzajazyri/components that referenced this issue Feb 18, 2023
…ing picked up in lazy-loaded modules

Along the same lines as angular#12934, where the consumer-provided instance was not being picked up within lazy-loaded modules. The fix also resolves an issue with the close button text when switching to French language in components-examples.

fixes angular#25021
hamzajazyri added a commit to hamzajazyri/components that referenced this issue Feb 19, 2023
…ing picked up in lazy-loaded modules

Along the same lines as angular#12934, where the consumer-provided instance was not being picked up within lazy-loaded modules. The fix also resolves an issue with the close button text when switching to French language in components-examples.

fixes angular#25021
hamzajazyri added a commit to hamzajazyri/components that referenced this issue Mar 7, 2023
…ing picked up in lazy-loaded modules

Along the same lines as angular#12934, where the consumer-provided instance was not being picked up within lazy-loaded modules. The fix also resolves an issue with the close button text when switching to French language in components-examples.

fixes angular#25021
hamzajazyri added a commit to hamzajazyri/components that referenced this issue Mar 7, 2023
…ing picked up in lazy-loaded modules

Along the same lines as angular#12934, where the consumer-provided instance was not being picked up within lazy-loaded modules. The fix also resolves an issue with the close button text when switching to French language in components-examples.

fixes angular#25021
hamzajazyri added a commit to hamzajazyri/components that referenced this issue Mar 7, 2023
Previously, the close calendar label was not updating correctly when switching languages. This commit fixes that issue.

Fixes: angular#25021
@Aadi1605
Copy link

Aadi1605 commented Mar 9, 2023

I believe this issue is still open, and you are welcome to work on it.

@piyushsrvastava
Copy link

i want to work on this issues please assign me issue

@piyushsrvastava
Copy link

function setCloseButtonLocale(locale) {
const closeButton = document.querySelector('.close-button');

switch (locale) {
case 'en-US':
closeButton.innerText = 'Close calendar';
break;
case 'fr-FR':
closeButton.innerText = 'Fermer le calendrier';
break;
// add additional cases for other supported locales
default:
closeButton.innerText = 'Close calendar';
}
}
you are using this code

@hamzajazyri
Copy link
Contributor

@piyushsrvastava, I wanted to bring to your attention that a pull request has already been submitted. #26738

crisbeto pushed a commit that referenced this issue Nov 9, 2023
Previously, the close calendar label was not updating correctly when switching languages. This commit fixes that issue.

Fixes: #25021
crisbeto pushed a commit that referenced this issue Nov 9, 2023
Previously, the close calendar label was not updating correctly when switching languages. This commit fixes that issue.

Fixes: #25021
(cherry picked from commit ff27a93)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/datepicker docs This issue is related to documentation good first issue This issue is a good place to start for first time contributors to the project P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
10 participants