Skip to content

Commit

Permalink
Fix: Tooltip - AbortController is not defined in SSR mode (Nuxt) (#4017
Browse files Browse the repository at this point in the history
…) (#4019)

* fix: Tooltip did not work in SSR due to AbortController

Fixes the bug that `Tooltip` did not work in Server Side Rendering
(SSR) due to `window.AbortController` use; i.e., no `window` is
available in SSR. Moves `window.AbortController` access inside the
`window` availability check.

* docs: update CHANGELOG

Adds unreleased entry for v0.9.29.
Lists the fix of the `window.AbortController` use in SSR.
  • Loading branch information
kikuomax committed Mar 6, 2024
1 parent 2454aa8 commit f3a964d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Buefy Changelog

## 0.9.29 Unreleased

### Fixes

* Fix [#4017](https://github.com/buefy/buefy/issues/4017) `Tooltip` - AbortController is not defined in SSR mode (Nuxt)

## 0.9.28

### New features
Expand Down
6 changes: 4 additions & 2 deletions src/components/tooltip/Tooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ export default {
}
},
mounted() {
this.controller = new window.AbortController()
if (this.appendToBody && typeof window !== 'undefined') {
this.controller = new window.AbortController()
this.$data._bodyEl = createAbsoluteElement(this.$refs.content)
this.updateAppendToBody()
// updates the tooltip position if the tooltip is inside
Expand Down Expand Up @@ -331,7 +331,9 @@ export default {
if (this.appendToBody) {
removeElement(this.$data._bodyEl)
}
this.controller.abort()
if (this.controller != null) {
this.controller.abort()
}
clearTimeout(this.timer)
clearTimeout(this.timeOutID)
}
Expand Down

0 comments on commit f3a964d

Please sign in to comment.