Fixed #5844 - Message props default value changes

pull/5848/head
tugcekucukoglu 2024-06-06 14:48:40 +03:00
parent 9f197f09b4
commit 8d2caf19dd
3 changed files with 10 additions and 23 deletions

View File

@ -12,15 +12,11 @@ export default {
}, },
closable: { closable: {
type: Boolean, type: Boolean,
default: true default: false
},
sticky: {
type: Boolean,
default: true
}, },
life: { life: {
type: Number, type: Number,
default: 3000 default: null
}, },
icon: { icon: {
type: String, type: String,

View File

@ -111,17 +111,18 @@ export interface MessageProps {
severity?: HintedString<'success' | 'info' | 'warn' | 'error' | 'secondary' | 'contrast'> | undefined; severity?: HintedString<'success' | 'info' | 'warn' | 'error' | 'secondary' | 'contrast'> | undefined;
/** /**
* Whether the message can be closed manually using the close icon. * Whether the message can be closed manually using the close icon.
* @defaultValue true * @defaultValue false
*/ */
closable?: boolean | undefined; closable?: boolean | undefined;
/** /**
* @deprecated since 4.0.
* When enabled, message is not removed automatically. * When enabled, message is not removed automatically.
* @defaultValue true * @defaultValue true
*/ */
sticky?: boolean | undefined; sticky?: boolean | undefined;
/** /**
* Delay in milliseconds to close the message automatically. * Delay in milliseconds to close the message automatically.
* @defaultValue 3000 * @defaultValue null
*/ */
life?: number | undefined; life?: number | undefined;
/** /**

View File

@ -40,28 +40,18 @@ export default {
visible: true visible: true
}; };
}, },
watch: {
sticky(newValue) {
if (!newValue) {
this.closeAfterDelay();
}
}
},
mounted() { mounted() {
if (!this.sticky) { if (this.life) {
this.closeAfterDelay(); setTimeout(() => {
this.visible = false;
this.$emit('life-end');
}, this.life);
} }
}, },
methods: { methods: {
close(event) { close(event) {
this.visible = false; this.visible = false;
this.$emit('close', event); this.$emit('close', event);
},
closeAfterDelay() {
setTimeout(() => {
this.visible = false;
this.$emit('life-end');
}, this.life);
} }
}, },
computed: { computed: {