1373
Views
8
Comments
[Input Masks Library] Cannot read property 'classList' of null
Question
input-masks-mobile
Reactive icon
Forge asset by Labs

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
2017-10-11 11-20-01
Maurilio Macedo

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')) {

UserImage.jpg
Jack.Wong

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!


UserImage.jpg
M I

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.

2018-05-03 15-48-34
Samuel Jesus
Staff

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

2022-03-16 12-33-27
Tiago Agostinho

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


2012-08-24 04-32-41
Juan Carlos Elorde

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

UserImage.jpg
M I

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.

2024-12-18 10-40-16
Renan Bernardelli

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".

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.