formBuilder icon indicating copy to clipboard operation
formBuilder copied to clipboard

bootstrap grid "t.classList is undefined" fixed

Open suleymantasci opened this issue 2 years ago • 4 comments

suleymantasci avatar Sep 27 '21 19:09 suleymantasci

I am still getting this error on Firefox.

I add an autocomplete field then click the pencil icon add any additional class other than form-control such as row-1 and then close the edit screen by clicking the pencil icon. You should get the error.

Goddard avatar Feb 18 '22 17:02 Goddard

@Goddard I guess Kevin didn't merge my edit. Get the formbuilder from github. Then replace src/js/layout.js with the one here. https://github.com/kevinchappell/formBuilder/blob/17e52f0350fcde02e6915b9e16cb30ef6e92d96a/src/js/layout.js Get build and use form-builder.js and form-render.js files prepared for you. It will not be a problem.

suleymantasci avatar Feb 19 '22 13:02 suleymantasci

@suleymantasci sorry just getting to this. Can you explain how this error occurs with steps to reproduce? I don't quite understand the problem or why it only occurs with those fields.

kevinchappell avatar Mar 08 '22 17:03 kevinchappell

Try this again with the latest version

Jojoshua avatar Mar 19 '22 03:03 Jojoshua

@suleymantasci thanks for submitting this PR. I wish I had got to it sooner but the issue seems resolved as I'm not able to reproduce the error. @lucasnetau is having a look as well, if the problem is gone PR will be closed.

kevinchappell avatar Sep 12 '23 04:09 kevinchappell

As it stands, this error cannot occur anymore due to the additional check for field.classList existence before calling field.classList.remove()

As to the correctness of the code, that's another issue. field.classList.remove(...classes) assumes we have a singular field and not a complex fragment, the original patch in the PR attempted to also fix this issue by looping through the child objects in a hard-coded manner to remove the classes.

adding this child iterator will fix that in a more generic fashion

    field.querySelectorAll('[class*=row-],[class*=col-]').forEach(element => {
      if (element.classList) {
        element.classList.remove(...classes)
      }
    })

lucasnetau avatar Sep 12 '23 05:09 lucasnetau

Alternate PR opened https://github.com/kevinchappell/formBuilder/pull/1412, closing this in favour of the new PR

lucasnetau avatar Sep 13 '23 03:09 lucasnetau