qontu / ngx-inline-editor

Native UI Inline-editor Angular (4.0+) component
https://qontu.github.io/ngx-inline-editor
MIT License
164 stars 90 forks source link

"Error: Uncaught (in promise): TypeError: Cannot read property 'length' of null" error thrown when using <inline-editor type="textarea" when [(ngModel)]="null" #92

Closed jmorganmartin closed 7 years ago

jmorganmartin commented 7 years ago

The error is fairly self-explanatory. Using version 0.2.0-alpha.11.

Here is my code:

<inline-editor type="textarea" [(ngModel)]="booking.description" (onSave)="updateBookingDescription($event)" cols="35" placeholder="Add Notes Here"></inline-editor>

If booking.description is null, triggers the error:

Error: Uncaught (in promise): TypeError: Cannot read property 'length' of null

The workaround is to write a quick check to prevent passing a variable that might be null (an empty string, '', is fine). I believe this issue is new to one of the recent updates.

Triggered in ngx-inline-editor.es5.js (line 235):

            var _a = this.config, min = _a.min, max = _a.max;
            var /** @type {?} */ length = this.isNumeric ? Number(value) : value.length;

If value is null, value.length triggers this error.

tonivj5 commented 7 years ago

Hi @jmorganmartin, thanks for your reporting and help! 👍

Yeah, it seems easy to fix. I will fix it when I have time (maybe, next weekend), however if you want help us, you could open a PR 😉

jmorganmartin commented 7 years ago

@xxxtonixxx I'm working on it right now. Ran into a separate issue trying to build.

jmorganmartin commented 7 years ago

https://github.com/qontu/ngx-inline-editor/pull/95

tonivj5 commented 7 years ago

Fixed in https://github.com/qontu/ngx-inline-editor/pull/95