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: {
type: Boolean,
default: true
},
sticky: {
type: Boolean,
default: true
default: false
},
life: {
type: Number,
default: 3000
default: null
},
icon: {
type: String,

View File

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

View File

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