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

fix(localize,form-core): wait for localize before updating feedback #1447

Merged
merged 1 commit into from
Jul 12, 2021

Conversation

jorenbroekema
Copy link
Collaborator

@jorenbroekema jorenbroekema commented Jul 7, 2021

fixes #1446

@changeset-bot
Copy link

changeset-bot bot commented Jul 7, 2021

🦋 Changeset detected

Latest commit: 8a76664

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 25 packages
Name Type
@lion/form-core Minor
@lion/localize Minor
@lion/checkbox-group Patch
@lion/combobox Patch
@lion/fieldset Patch
@lion/form-integrations Patch
@lion/input-amount Patch
@lion/input-date Patch
@lion/input-datepicker Patch
@lion/input-email Patch
@lion/input-iban Patch
@lion/input-stepper Patch
@lion/input Patch
@lion/listbox Patch
@lion/radio-group Patch
@lion/select-rich Patch
@lion/select Patch
@lion/switch Patch
@lion/textarea Patch
@lion/validate-messages Patch
@lion/calendar Patch
@lion/input-range Patch
@lion/pagination Patch
@lion/progress-indicator Patch
@lion/form Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

await el.updateComplete;
await el.feedbackComplete;
expect(el.label).to.equal('Tekst');
expect(_feedbackNode.feedbackData?.[0].message).to.equal('Vul een Tekst in.');
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was failing because "Tekst" was still "Text" from the old locale. Now that it awaits localize.loadingComplete, it will get the right localized label in the feedback message

@tlouisse
Copy link
Member

tlouisse commented Jul 11, 2021

Nice catch and fix.

Maybe we can solve it in a way such that ValidateMixin (and with that the complete form-core package) becomes i18n system agnostic?
See: https://github.com/ing-bank/lion/blob/master/packages/form-core/src/validate/ValidateMixin.js#L3 😬

We should actually get rid of the lines here: https://github.com/ing-bank/lion/blob/master/packages/form-core/src/validate/ValidateMixin.js#L256

Maybe we can solve it with a controller, like this?

form-core: localization system agnostic


// ValidateManager
export class ValidateManager {    
  addLocalizeController(ctrl) {       
    this.localizeControllers.push(ctrl);    
  }
}
ValidateManager.localizeControllers = [];
// ValidateMixin

import { ValidateManager } from ./ValidateManager.js’;



...
constructor() {  

ValidateManager.localizeControllers.forEach(ctrl => {
    ctrl(this);
  });
}


...

validate-messages


import { ValidateManager } from @lion/form-core’;

import {localize} from @lion/localize;



ValidateManager.addLocalizeController(class LionLocalizeController { 
 ...
hostConnected() {   
   localize.addEventListener('localeChanged', this._updateValidateMixinFeedbackComponent);  
}  
...
async _updateValidateMixinFeedbackComponent(ev) {	
  await localize.loadingComplete;	
  this.host._updateFeedbackComponent(ev);  
}
});

@tlouisse
Copy link
Member

If the proposal is a bit too much and you need the fix on a short term, we can also merge this fix and add the proposal as an issue/idea 👍

@gerjanvangeest gerjanvangeest merged commit 74c627a into master Jul 12, 2021
@gerjanvangeest gerjanvangeest deleted the fix/feedback-label branch July 12, 2021 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[validate] Validation Feedback "fieldName" timing issue with localization
3 participants