Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a
- [Introduction](#introduction)
- [Table of Contents](#table-of-contents)
- [Installation](#installation)
- [Test](#test)
- [Usage](#usage)
- [For Vue 3](#for-vue-3)
- [For Nuxt 3](#for-nuxt-3)
Expand Down Expand Up @@ -74,6 +75,33 @@ or
yarn add vue-sonner
```

## Test

To run the test you need two separate CLI window :

### Launching the test

To launch the test, you need to go in the test directory

```bash
cd ./test
```

and launch the following command

```bash
cd ./test
pnpm test:e2e --ui
```

### Build and watch for change in order to fix the test

This command will build the vue-sonner library in lib mode, and add a watch so every time you modify the code of the library, you will have a new bundle and can run the test again.

```bash
pnpm build:dev
```

## Usage

### For Vue 3
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"author": "xiaoluoboding <xiaoluoboding@gmail.com>",
"scripts": {
"dev": "vite",
"build:dev": "vite build --mode lib --watch",
"build:docs": "vite build --mode docs",
"build:lib": "vite build --mode lib && pnpm run build:types",
"build:types": "vue-tsc -p tsconfig.build.json && api-extractor run",
Expand Down
15 changes: 9 additions & 6 deletions packages/Toast.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
<script lang="ts" setup>
import './styles.css'

import { computed, onMounted, onUnmounted, ref, watchEffect } from 'vue'
import { computed, onMounted, onUnmounted, ref, watch, watchEffect } from 'vue'
import { type HeightT, type ToastProps, type ToastT, isAction } from './types'
import { useIsDocumentHidden } from './hooks'

Expand Down Expand Up @@ -407,11 +407,14 @@ watchEffect((onInvalidate) => {
})
})

// watchEffect(() => {
// if (props.toast.delete) {
// deleteToast()
// }
// })
watch(
() => props.toast.delete,
(value) => {
if (value) {
deleteToast()
}
}
)

onMounted(() => {
if (toastRef.value) {
Expand Down
19 changes: 6 additions & 13 deletions packages/Toaster.vue
Original file line number Diff line number Diff line change
Expand Up @@ -343,20 +343,13 @@ watch(
}
)

watch(
() => listRef.value,
() => {
if (listRef.value) {
return () => {
if (lastFocusedElementRef.value) {
lastFocusedElementRef.value.focus({ preventScroll: true })
lastFocusedElementRef.value = null
isFocusWithinRef.value = false
}
}
}
watchEffect(() => {
if (listRef.value && lastFocusedElementRef.value) {
lastFocusedElementRef.value.focus({ preventScroll: true })
lastFocusedElementRef.value = null
isFocusWithinRef.value = false
}
)
})

watchEffect(() => {
// Ensure expanded is always false when no toasts are present / only one left
Expand Down
68 changes: 68 additions & 0 deletions playwright-report/index.html

Large diffs are not rendered by default.

Loading