ngx-autosize
ngx-autosize copied to clipboard
wrong emitted height in components with ChangeDetectionStrategy.OnPush
If this plugin is used within components that have the OnPush change detection strategy, the initial height is incorrect.
My guess is that the height of the clone (https://github.com/chrum/ngx-autosize/blob/master/projects/autosize/src/lib/autosize.directive.ts#L148) is not correct. A possible fix could be to run https://angular.io/api/core/ChangeDetectorRef#detectChanges or wrap the code in a setTimeout.
sweet :) i just reproduced it, great finding!
hey @capc0
Its a bit difficult to crack the problem. I noticed that its not really the thing with onPush strategy but with textarea packed in a component that receives value through inputs... its also problematic when textarea gets autosized immediately after app starts...
...anyway :) i fixed what i was able to reproduce (all described above) so check 'next' channel please:
npm install ngx-autosize@next
if this doesnt help then can you do me a favor and put some example repo with the bug?
hi thanks for your feedback. unfortunately the @next version did not fix the problem for me. I will try to provide you a example repo within the next few days :)
Issue is reproducable here: https://stackblitz.com/edit/angular-jxkwwz?file=src/app/textarea-input/textarea-input.component.html
If you load the page, it shows 5 lines
Clicking inside the textarea and then somewhere else in the document again increases the height
But it seems to be related to bootstrap, since If I remove the imports in the index.html
it looks OK.
Same issue :)
Didn't get initial height. Need to focus in field to have correct size.
More information:
This occur mainly when field is hidden when page is loaded. I receive onResize event with value "NaN".
Here is my workaround:
Hi, I am facing the same issue any updates on this?