fix(Table): checkbox still emit @select event (#3269)

Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
kyyy
2025-04-22 22:01:44 +07:00
committed by GitHub
parent a58efd23aa
commit c0e14d006e

View File

@@ -93,15 +93,17 @@
/> />
</td> </td>
<td v-for="(column, subIndex) in columns" :key="subIndex" :class="[ui.td.base, ui.td.padding, ui.td.color, ui.td.font, ui.td.size, column?.rowClass, row[column.key]?.class, column.key === 'select' && ui.checkbox.padding]"> <td v-for="(column, subIndex) in columns" :key="subIndex" :class="[ui.td.base, ui.td.padding, ui.td.color, ui.td.font, ui.td.size, column?.rowClass, row[column.key]?.class, column.key === 'select' && ui.checkbox.padding]">
<slot v-if="modelValue && column.key === 'select' " name="select-data" :checked="isSelected(row)" :change="ev => onChangeCheckbox(ev, row)"> <!-- This is a workaround: Since the @change event doesn't bubble up naturally, we need to wrap it in another element and use @click.capture.stop to simulate event bubbling behavior -->
<UCheckbox <span v-if="modelValue && column.key === 'select' " @click.capture.stop="() => {}">
:model-value="isSelected(row)" <slot name="select-data" :checked="isSelected(row)" :change="(ev: boolean) => onChangeCheckbox(ev, row)">
v-bind="ui.default.checkbox" <UCheckbox
aria-label="Select row" :model-value="isSelected(row)"
@change="onChangeCheckbox($event, row)" v-bind="ui.default.checkbox"
/> aria-label="Select row"
</slot> @change="onChangeCheckbox($event, row)"
/>
</slot>
</span>
<slot <slot
v-else v-else
:name="`${column.key}-data`" :name="`${column.key}-data`"