CHIPS - label crossed by top border when initialized via jav


Topic: CHIPS - label crossed by top border when initialized via javascript

meesha81 pro premium priority asked 3 weeks ago

Expected behavior Valid input label, which is not crossed by top border of element.

Actual behavior Label is crossed with the input border when initialized via javascript. Creation and initialization of from-outline, label, input has propably bug when initialized with javascript.

Because of broken snippet creation, I cannot create it, but I hope you can copy&paste some example to the clean page and you can see it quickly.

If I do something wrong, please tell me how to fix it.


Kamila Pieńkowska staff answered 3 weeks ago

This example in the docs is initiated via JS: https://mdbootstrap.com/docs/standard/components/chips/#section-new-initial

As you can see, the label is working as expected. Please share the exact code that produces the issue you're describing, and I’ll be happy to help you identify the problem.


meesha81 pro premium priority commented 3 weeks ago

Snippets is not working for me…


Kamila Pieńkowska staff commented 3 weeks ago

Then paste the code as is in here.


meesha81 pro premium priority commented 3 weeks ago

It is really not working, but important difference is that you have to try it in the modal. Snippet is important to show the issue and it is fine that is can be created now.

https://mdbootstrap.com/snippets/standard/meesha81/6445110#html-tab-view


Arkadiusz Idzikowski staff answered 3 weeks ago

Thank you for the clarification. It seems like the problem is caused by the fact, that the component is not loaded properly at the time of the Javascript initialization (because it is hidden in the modal).

We will take a closer look at that. For now please try to delay the component init until the modal opens. Here is an example:

chipsLoaded = false;

const myModalEl = document.getElementById('exampleModal')
    myModalEl.addEventListener('shown.mdb.modal', (e) => {
      if (!chipsLoaded) {
        const chipsInitialNew = document.querySelector('.chips-test')

        const newChipsNew = new mdb.ChipsInput(chipsInitialNew, {
          initialValues: [
            { tag: 'MDBReact' },
            { tag: 'MDBAngular' },
            { tag: 'MDBVue' },
            { tag: 'MDB5' },
            { tag: 'MDB' }
          ]
        });

        chipsLoaded = true;
    }
});

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 9.1.0
  • Device: PC
  • Browser: Chrome
  • OS: Win11
  • Provided sample code: No
  • Provided link: No