themesberg / flowbite-vue

Official Vue 3 components built for Flowbite and Tailwind CSS
https://flowbite-vue.com
MIT License
723 stars 116 forks source link

`FwbDropdown` content's position doesn't change with its width and height #276

Closed AnotiaWang closed 3 months ago

AnotiaWang commented 5 months ago

When a dropdown is active and its content changed, the top of content no longer stays right below the dropdown button. In my case, there is a div (with overflow-y-auto) that contains many dropdowns. So if the dropdown at the top of the div overflows upwards, the content inside cannot be seen.

Example:

<FwbDropdown text="Dropdown" close-inside>
  <FwbListGroup>
    <FwbListGroupItem v-for="i in items" :key="i">
      {{ i }}
    </FwbListGroupItem>
  </FwbListGroup>
</FwbDropdown>
const items = ref<string[]>([])

// Click the dropdown to activate it before this timeout ends
setTimeout(() => {
  items.value.push('1', '2', '3')
}, 3000)

Before: 截屏2024-03-15 21 17 45

After: Expected Actual
截屏2024-03-15 21 18 02 截屏2024-03-15 21 17 56

Same issue when I remove items from the dropdown content. 截屏2024-03-15 21 40 43

AnotiaWang commented 5 months ago

Maybe call the calculatePlacementClasses() function in useDropdownClasses.ts when the slot content is changed? Or expose the util function and let users to decide when to refresh the position

Edit: Opened a PR to fix this, please review.