Skip to content

Commit

Permalink
fix(angular): race condition when [maskitoOptions] are changed befo…
Browse files Browse the repository at this point in the history
…re long element predicate is resolved (#1696)
  • Loading branch information
nsbarsukov authored Sep 25, 2024
1 parent 63d6c8a commit 9f9bad3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
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

0 comments on commit 9f9bad3

Please sign in to comment.