Skip to content

Commit

Permalink
chore: add prop, block toggling when disabled, ensure readability, fi…
Browse files Browse the repository at this point in the history
…x linting errors
  • Loading branch information
tho-dan committed Jan 13, 2025
1 parent 19dfd25 commit 122388c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions docs/components/dropdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ Please note that this has to be manually implemented when using a custom trigger
```vue
<template>
<fwb-dropdown text="Normal state">
Access this content by clicking the dropdown's trigger button
Dropdown content
</fwb-dropdown>
<fwb-dropdown text="Disabled state" disabled>
You cannot access this content, since the dropdown's trigger button is disabled
Disabled dropdown content
</fwb-dropdown>
</template>
Expand Down Expand Up @@ -327,6 +327,7 @@ import { FwbDropdown, ListGroup, ListGroupItem } from 'flowbite-vue'
| placement | `DropdownPlacement` | `'bottom'` |
| text | `string` | `''` |
| color | `ButtonVariant` | `'default'` |
| disabled | `boolean` | `false` |
| transition | `string` | `''` |
| closeInside | `boolean` | `false` |
| alignToEnd | `boolean` | `false` |
Expand Down
10 changes: 8 additions & 2 deletions src/components/FwbDropdown/FwbDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
<div class="inline-flex items-center">
<fwb-slot-listener @click="onToggle">
<slot name="trigger">
<fwb-button :disabled="disabled" :color="color">
<fwb-button
:disabled="disabled"
:color="color"
>
{{ text }}
<template #suffix>
<svg
Expand Down Expand Up @@ -56,7 +59,10 @@ const visible = ref(false)
const onHide = () => {
if (props.closeInside) visible.value = false
}
const onToggle = () => (visible.value = !visible.value)
const onToggle = () => {
if (props.disabled) return
visible.value = !visible.value
}
const props = withDefaults(
defineProps<{
Expand Down

0 comments on commit 122388c

Please sign in to comment.