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(hidden-input) input programmatically value set without phantom values #864

Merged
merged 4 commits into from
Mar 19, 2021
Merged

Conversation

BGBRWR
Copy link
Contributor

@BGBRWR BGBRWR commented Feb 4, 2021

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #863 #706

What is the new behavior?

It works

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Empty string is no longer converted to zero.
Number('') === 0;
This was returning inconsistent values when input values were deleted.
@Yumitoya8569
Copy link

hi @BGBRWR , I have the same problem #863,
after review this fix, it doesn't pass the following test :

  // in secure-mask.spec.ts
  it('it checks secure input functionality on setValue(longer string)', () => {
    component.mask = 'XXX/X0/0000';
    component.hiddenInput = true;
    typeTest('54321', fixture);
    component.form.setValue('1234567');
    fixture.whenStable().then(() => {
      expect(fixture.nativeElement.querySelector('input').value).toBe('***/*5/67');
    });
  });

please try this :

  // in mask.service.ts line 58
  if (this.hiddenInput ) { // original
  if (this.hiddenInput && !this.writingValue) { // suggestion

the following change is not necessary i think :

[mask.service.ts line 73-76]
[secure-mask.spec.ts line 64-72]

in real world, users typing can't change element value '54321' to '1' without range selection

@BGBRWR
Copy link
Contributor Author

BGBRWR commented Mar 4, 2021

I added your test and suggestion. Good catch!

newInputValue =
this.actualValue.length && actualResult.length <= inputValue.length
? this.shiftTypedSymbols(actualResult.join(''))
: inputValue;

These code (^^^) is need for when you reset the form and then type values.

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.

3 participants