8000 fix: `CCloseButton` events issue · imhamad/coreui-vue@baf2cfa · GitHub
[go: up one dir, main page]

Skip to content

Commit baf2cfa

Browse files
committed
fix: CCloseButton events issue
1 parent 945733b commit baf2cfa

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

src/components/alert/CAlert.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const CAlert = defineComponent({
4646
],
4747
setup(props, { slots, emit }) {
4848
const visible = ref(props.visible)
49-
const dismiss = () => {
49+
const handleDismiss = () => {
5050
visible.value = false
5151
emit('dismiss')
5252
}
@@ -82,7 +82,7 @@ export const CAlert = defineComponent({
8282
props.dismissible &&
8383
h(CCloseButton, {
8484
onClick: () => {
85-
dismiss()
85+
handleDismiss()
8686
},
8787
}),
8888
],

src/components/close-button/CCloseButton.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export const CCloseButton = defineComponent({
1818
required: false,
1919
},
2020
},
21-
setup(props) {
21+
emits: ['click'],
22+
setup(props, { emit }) {
23+
const handleClick = () => {
24+
emit('click')
25+
}
2226
return () =>
2327
h('button', {
2428
class: [
@@ -31,6 +35,7 @@ export const CCloseButton = defineComponent({
3135
],
3236
'aria-label': 'Close',
3337
disabled: props.disabled,
38+
onClick: handleClick,
3439
})
3540
},
3641
})

src/components/toast/CToastClose.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const CToastClose = defineComponent({
1414
},
1515
...CCloseButton.props,
1616
},
17+
emits: ['dismiss'],
1718
setup(props, { slots, emit }) {
1819
const updateVisible = inject('updateVisible') as any
1920
const handleClose = () => {

src/components/toast/CToastHeader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const CToastHeader = defineComponent({
77
/**
88
* Automatically add a close button to the header.
99
*/
10-
dismiss: {
10+
close: {
1111
type: Boolean,
1212
require: false,
1313
},
@@ -22,7 +22,7 @@ const CToastHeader = defineComponent({
2222
return () =>
2323
h('div', { class: 'toast-header' }, [
2424
slots.default && slots.default(),
25-
props.dismiss &&
25+
props.close &&
2626
h(CToastClose, {
2727
onClose: () => handleClose(),
2828
}),

0 commit comments

Comments
 (0)
0