1092
Views
8
Comments
[Input Masks Library] Cannot read property 'classList' of null
Question
Forge component by Labs
12
Published on 19 Feb 2021

Hi there,

I am using the credit card mask but i keep receveing the error Cannot read property 'classList' of null every time i change the input. (check the attached image)

My implementation is exactly the same as the one from Demo provided.

Any insights?

Untitled.png

Rank: #2393

Temporary solution!

In the FindClosest action, at line 19 of JS, add the check before: [element.parentElement !== null && ...]

Corrected line:

if(element.parentElement !== null && !element.parentElement.classList.contains('screen')) {

Rank: #3427

Maurilio Macedo wrote:

Temporary solution!

In the FindClosest action, at line 19 of JS, add the check before: [element.parentElement !== null && ...]

Corrected line:

if(element.parentElement !== null && !element.parentElement.classList.contains('screen')) {

Thank you for your solution, it's work!


Rank: #46037

Maurilio Macedo wrote:

Temporary solution!

In the FindClosest action, at line 19 of JS, add the check before: [element.parentElement !== null && ...]

Corrected line:

if(element.parentElement !== null && !element.parentElement.classList.contains('screen')) {

Hi,

In my Reactive application, every time I access the page, it shows that null error and the input field is always non-editable, even when it's dynamically enabled.

Where exactly can I find that 'FindClosest' action? Also, would it resolve the issue regarding the input field being non-editable?

Thank you.

Staff
Rank: #206

Hello,

I've talked with Pedro Domingues, and the issue is being caused by the fact that the component was used in an empty screen, without any layout. With the layout, the problem stopped.

Nevertheless, we will add this to our backlog to improve the component.


Also, Maurilio is right: changing that line will prevent the issue from happening. However, in this particular case, since the screen class was never there, the functionality would still be impacted.


Cheers,

Samuel Jesus

Rank: #1769

Samuel Jesus wrote:

Hello,

I've talked with Pedro Domingues, and the issue is being caused by the fact that the component was used in an empty screen, without any layout. With the layout, the problem stopped.

Nevertheless, we will add this to our backlog to improve the component.


Also, Maurilio is right: changing that line will prevent the issue from happening. However, in this particular case, since the screen class was never there, the functionality would still be impacted.


Cheers,

Samuel Jesus


Hi! 

I'm having the same problem and I'm using the component with layout.

But the Maurilio Macedo solution works fine. 


Thanks


Just downloaded this component and it still has the error :)

Rank: #46037

Hi,

I've managed to find that action and changed that specific line. However, the input still remains non-editable. Do you know why?

Thank you.

Hi, I have the same issue, but in my case, I'm trying to use it in the currency format. Adding the code "element.parentElement !== null && " the error message doesn't appear but the input become "disable".