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(angular): race condition when [maskitoOptions] are changed before long element predicate is resolved #1696

Merged
merged 1 commit into from
Sep 25, 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
4 changes: 2 additions & 2 deletions projects/angular/src/lib/maskito.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ export class MaskitoDirective implements OnDestroy, OnChanges {
const predicateResult = await elementPredicate(elementRef);

// eslint-disable-next-line unicorn/consistent-destructuring
if (this.elementPredicate !== elementPredicate) {
if (this.elementPredicate !== elementPredicate || this.options !== options) {
// Ignore the result of the predicate if the
// maskito element has changed before the predicate was resolved.
// maskito element (or its options) has changed before the predicate was resolved.
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,12 @@ describe('@maskito/angular | Predicate', () => {
cy.get('input').focus().type('12abc3').should('have.value', '12abc3');
});

// TODO: uncomment in this PR https://github.com/taiga-family/maskito/pull/1608
it.skip('enabling of the first mask should be skipped if [maskitoOptions] were changed during resolving of element predicate', () => {
it('enabling of the first mask should be skipped if [maskitoOptions] were changed during resolving of element predicate', () => {
cy.smartTick(PREDICATE_RESOLVING_TIME, {fixture}); // predicate is resolved only once for digit cases
cy.get('input').focus().type('12abc3').should('have.value', '12abc3');
});

// TODO: uncomment in this PR https://github.com/taiga-family/maskito/pull/1608
it.skip('only the last mask should be applied if [maskitoOptions] were changed during resolving of element predicates', () => {
it('only the last mask should be applied if [maskitoOptions] were changed during resolving of element predicates', () => {
cy.smartTick(SWITCH_OPTIONS_TIME + PREDICATE_RESOLVING_TIME, {fixture}); // enough time to resolve element predicated for both cases
cy.get('input').focus().type('12abc3').should('have.value', 'abc');
});
Expand Down
Loading