unovue / radix-vue

Vue port of Radix UI Primitives. An open-source UI component library for building high-quality, accessible design systems and web apps.
https://radix-vue.com
MIT License
3.69k stars 228 forks source link

fix(Toast): negative duration #1429

Closed sandros94 closed 5 days ago

sandros94 commented 5 days ago

This is a follow-up from https://github.com/nuxt/ui/issues/2665

Currently the Toast's duration only starts the timer if false or infinite.

But having a negative duration should also trigger a Toast without a timer.

zernonia commented 5 days ago

Hi @sandros94 ! Thanks for the PR. I think your proposal make sense 👍🏻

zernonia commented 5 days ago

In order to support :duration="0", we need to adjust this to nullish coalescing operator as well

const duration = computed(() => props.duration && providerContext.duration.value)

https://github.com/unovue/radix-vue/pull/1429/files#diff-6607e968a50b4047c4bce25917a099b696a722e27d44e742a9ad7572a96e0b72R69-R70

sandros94 commented 5 days ago

we need to adjust this to nullish coalescing operator as well

instead of a nullish coalescing operator (that would return undefined if props.duration isn't set) I decided to explicitly check if the type is a number, otherwise use the provider's value/default