[Input Masks Library] Cannot read property 'classList' of null

Forge Component
(10)
Published on 2 Oct by Labs
10 votes
Published on 2 Oct 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?

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

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

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

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