Skip to content

Commit 285389a

Browse files
committed
HUB-8864: fix toasts not expanding bug
HUB-8864 (Toast do not expand after being in back of stack)
1 parent 0d76bc9 commit 285389a

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

.changeset/little-suns-build.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@knime/components": patch
3+
---
4+
5+
fix toasts not expanding after being in back of stack

packages/components/src/components/Toast/components/Toast.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ const isTruncated = ref(isTruncatable);
7272
const showMore = () => {
7373
// TODO HUB-5698: animate toast and stack height when expanding truncated text
7474
isTruncated.value = false;
75+
if (toastRef.value !== null) {
76+
// reset height if it has been set in animateHeightTo
77+
toastRef.value.style.height = "unset";
78+
}
7579
};
7680
7781
// Height transformations
@@ -162,7 +166,7 @@ watch(toRef(props, "active"), (active) => {
162166
<template v-else>{{ message }}</template>
163167
</div>
164168
<div v-else-if="props.component" class="message">
165-
<component :is="props.component" />
169+
<component :is="props.component" @show-more="showMore" />
166170
</div>
167171

168172
<div v-if="buttons.length" class="buttons">

packages/components/src/components/Toast/components/templates/ApiErrorTemplate.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ interface ApiErrorTemplateProps {
1818
}
1919
2020
const props = defineProps<ApiErrorTemplateProps>();
21+
const emits = defineEmits(["showMore"]);
2122
2223
const { copy, copied } = useClipboard({
2324
copiedDuring: 3000,
@@ -68,14 +69,19 @@ const errorForClipboard = computed(() => {
6869
const copyToClipboard = () => {
6970
copy(errorForClipboard.value);
7071
};
72+
73+
const onShowDetailsClicked = () => {
74+
showDetails.value = true;
75+
emits("showMore");
76+
};
7177
</script>
7278

7379
<template>
7480
<div class="wrapper">
7581
<div class="title">
7682
{{ props.title }}
7783
</div>
78-
<button v-if="!showDetails" class="show-more" @click="showDetails = true">
84+
<button v-if="!showDetails" class="show-more" @click="onShowDetailsClicked">
7985
Show details
8086
</button>
8187
<div v-if="showDetails" class="additional-info">

packages/components/src/components/Toast/components/templates/__tests__/ApiErrorTemplate.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,10 @@ describe("ApiErrorTemplate", () => {
100100
await wrapper.find("button").trigger("click");
101101
expect(wrapper.find("button").text()).toBe("Error was copied");
102102
});
103+
104+
it("emits showMore event", async () => {
105+
const { wrapper } = doMount();
106+
await wrapper.find("button").trigger("click");
107+
expect(wrapper.emitted("showMore")).toBeDefined();
108+
});
103109
});

0 commit comments

Comments
 (0)