question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vue 3 - js functionality not working

See original GitHub issue

Hi, I am using flowbite with Vue 3 and am having problems with getting javascript functionality (e.g. dropdowns, tooltips, etc.) to work. Doesn’t matter if I try with “plain” flowbite (npm package) or install both, flowbite + flowbite-vue. Simple flowbite js, like tooltips, just doesn’t work. No tooltip is shown…

Example code (taken from first tooltip example):

<button data-tooltip-target="tooltip-default" type="button" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">Default tooltip</button>
<div id="tooltip-default" role="tooltip" class="inline-block absolute invisible z-10 py-2 px-3 text-sm font-medium text-white bg-gray-900 rounded-lg shadow-sm opacity-0 transition-opacity duration-300 tooltip dark:bg-gray-700">
    Tooltip content
    <div class="tooltip-arrow" data-popper-arrow></div>
</div>

What could be the problem here?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
potkotcommented, Nov 30, 2022

Answered a similar question here https://github.com/themesberg/flowbite/issues/231#issuecomment-1332420474

Maybe someone will help

1reaction
ii64commented, Nov 6, 2022

Hi, I got the same issue with Modal component. The demo code on https://flowbite-vue.com/components/modal/modal.html doesn’t pop up any modal, however forcing it by using Modal from flowbite able to show the modal but interactions (modal close, and action) still broken.

onMounted(() => {
  return;
  const targetEl = document.getElementById('defaultModal');

  // options with default values
  const options = {
    placement: 'center',
    backdropClasses: 'bg-gray-900 bg-opacity-50 dark:bg-opacity-80 fixed inset-0 z-40',
    onHide: () => {
      console.log('modal is hidden');
    },
    onShow: () => {
      console.log('modal is shown');
    },
    onToggle: () => {
      console.log('modal has been toggled');
    },
  };
  modal.value = new Modal(targetEl, options);
});

I am using flowbite@1.5.0, flowbite-vue@^0.0.6 on vue@^3.2.41 and vite. Did I missed something here? Also, I tried to check the flowbite-vue source on node_modules (bundled) it seem did not match with the current source code:

Here, div does not have id and no hidden in classList: https://github.com/themesberg/flowbite-vue/blob/c658c323cd93fb2c7a17de7f23601dd9900d89b8/src/components/Modal/Modal.vue#L4-L7

But on the bundled source code, it appends id defaultModal and hidden class:

Bundled
const _hoisted_1$a = {
  id: "defaultModal",
  tabindex: "-1",
  "aria-hidden": "true",
  class: "hidden overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 w-full md:inset-0 h-modal md:h-full"
};
const _hoisted_2$a = /* @__PURE__ */ createStaticVNode('<div class="relative p-4 w-full max-w-2xl h-full md:h-auto"><div class="relative bg-white rounded-lg shadow dark:bg-gray-700"><div class="flex justify-between items-start p-4 rounded-t border-b dark:border-gray-600"><h3 class="text-xl font-semibold text-gray-900 dark:text-white"> Terms of Service </h3><button type="button" class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 ml-auto inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white" data-modal-toggle="defaultModal"><svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg></button></div><div class="p-6 space-y-6"><p class="text-base leading-relaxed text-gray-500 dark:text-gray-400"> With less than a month to go before the European Union enacts new consumer privacy laws for its citizens, companies around the world are updating their terms of service agreements to comply. </p><p class="text-base leading-relaxed text-gray-500 dark:text-gray-400"> The European Union\u2019s General Data Protection Regulation (G.D.P.R.) goes into effect on May 25 and is meant to ensure a common set of data rights in the European Union. It requires organizations to notify users as soon as possible of high-risk data breaches that could personally affect them. </p></div><div class="flex items-center p-6 space-x-2 rounded-b border-t border-gray-200 dark:border-gray-600"><button data-modal-toggle="defaultModal" type="button" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">I accept</button><button data-modal-toggle="defaultModal" type="button" class="text-gray-500 bg-white hover:bg-gray-100 focus:ring-4 focus:outline-none focus:ring-blue-300 rounded-lg border border-gray-200 text-sm font-medium px-5 py-2.5 hover:text-gray-900 focus:z-10 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-500 dark:hover:text-white dark:hover:bg-gray-600 dark:focus:ring-gray-600">Decline</button></div></div></div>', 1);
const _hoisted_3$8 = [
  _hoisted_2$a
];
const _sfc_main$b = /* @__PURE__ */ defineComponent({
  __name: "Modal",
  props: {
    children: {
      type: Array,
      default() {
        return [];
      }
    },
    popup: {
      type: Boolean,
      default: false
    },
    position: {
      type: String,
      default: "center"
    },
    show: {
      type: Boolean,
      default: false
    },
    size: {
      type: String,
      default: "2xl"
    }
  },
  setup(__props) {
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1$a, _hoisted_3$8);
    };
  }
});

Demo: https://www.youtube.com/watch?v=V4q9M7iaYEY

Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue 3 use function not works - Stack Overflow
I tried to upgrade one of my apps from Vue 2 to Vue 3. Unfortunately I can't use: Vue.use() function. For example my...
Read more >
5 common problems with Vue.js - Medium
5 common problems with Vue.js · 1. Why is “this” undefined? · 2. Make VueJS and jQuery play nice · 3. Update parent...
Read more >
Reactivity Fundamentals - Vue.js
Vue will call the function when creating a new component instance, and wrap the ... In Vue 3, data is made reactive by...
Read more >
Creating a Project | Vue CLI
If you are on Windows using Git Bash with minTTY, the interactive prompts will not work. You must launch the command as winpty...
Read more >
Components Basics - Vue.js
When not using a build step, a Vue component can be defined as a plain JavaScript ... To solve this problem, components provide...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found