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

Null input fix #95

Merged
merged 3 commits into from
Sep 25, 2017
Merged

Null input fix #95

merged 3 commits into from
Sep 25, 2017

Conversation

jmorganmartin
Copy link
Contributor

@jmorganmartin jmorganmartin commented Sep 15, 2017

First commit prevents errors / false-positives on length and RegExp checks if input value is null or false.

2nd commit updates package.json to prevent build error/conflict with gulp-rollup@2.15.0

@tonivj5
Copy link
Collaborator

tonivj5 commented Sep 16, 2017

Thanks @jmorganmartin for your fantastic work! I will review soon 👍

Copy link
Collaborator

@tonivj5 tonivj5 left a comment

Choose a reason for hiding this comment

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

Thanks 👍

@@ -162,7 +162,7 @@ export class InputBase implements OnInit, OnChanges, DoCheck,
const { value } = this.state.getState();

if (this.canTestRegex(this.config)) {
if (!new RegExp(this.config.pattern as string).test(value)) {
if (!new RegExp(this.config.pattern as string).test((value !== null && value !== false) ? value : '')) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It should be value != null && value !== false because undefined is convert to string too (value != null check null and and `undefinedp ). And I think it would be clearest without brkackets 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since it's Typescript, can we just do .test(value ? value : '') ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess, not because it could be 0.

@jmorganmartin
Copy link
Contributor Author

@xxxTonixxx Updated with your suggestion. Let me know if I can help get this released. It's causing a lot of errors in one of my projects.

Copy link
Collaborator

@tonivj5 tonivj5 left a comment

Choose a reason for hiding this comment

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

😄

@tonivj5 tonivj5 merged commit 76fa838 into qontu:master Sep 25, 2017
@tonivj5
Copy link
Collaborator

tonivj5 commented Sep 25, 2017

Thanks @jmorganmartin for your work! I just have uploaded a new version 0.2.0-alpha.12 ! I hope it helps in your projects 👍

@360disrupt
Copy link

Version 0.2.0-alpha.12
I have

    const expertiseForm = this.formBuilder.group({
      language: [ '' ],
      description: [ null ],
      since: [ undefined ],
    });
<form [formGroupName]="index" [id]="'expertise'+index">
            {{returnType(expertise.get('language').value)}}
            <div class="row">
              <div class="form-group required col-xs-12 col-md-12">
                <label class="inline-control-label">Language</label>
                <inline-editor type="text" class="inline-form-control" empty="type in your language e.g. JS" (onSave)="checkMe($event)" formControlName="language" placeholder="E.g. javascript" required></inline-editor>
              </div>
            </div>

None of the three options shows the empty value instead nothing is shown => thus nothing is editable.

bildschirmfoto 2019-01-30 um 10 26 59

If I enter string values it works:
bildschirmfoto 2019-01-30 um 10 29 14

Problem only appears if the initial value is null|undefined|'' this works:
setTimeout( () => expertiseForm.patchValue({ language: null, description: null, since: null }), 1000)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants