Skip to content

Commit

Permalink
fix: floating vue hydration mismatch (#3526)
Browse files Browse the repository at this point in the history
The VDropdown component from the floating-vue lib results in a hydration errors due to the way the lib edits the dom
issue is reported: Akryum/floating-vue#1006

Workaround implemented as proposed in: Akryum/floating-vue#1006 (comment)
  • Loading branch information
connoratrug committed Mar 21, 2024
1 parent 872d790 commit b5f364c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions apps/nuxt3-ssr/components/BottomModal.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
const ariaId = useId();
const preAnimation = () => {
document.body.classList.add("v-popper_bottom");
};
Expand Down Expand Up @@ -29,6 +30,7 @@ const emit = defineEmits(["close"]);

<template>
<VDropdown
:aria-id="ariaId"
:shown="show"
:positioning-disabled="true"
@show="preAnimation()"
Expand Down
4 changes: 3 additions & 1 deletion apps/nuxt3-ssr/components/FilterWell.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
const ariaId = useId();
const props = defineProps<{
filters: [];
}>();
Expand Down Expand Up @@ -51,7 +52,7 @@ function isAFilterSet(filters) {
Active filters
</div>
<div class="flex flex-wrap gap-3 content-around p-3">
<template v-for="filter in filters">
<template v-for="(filter, index) in filters">
<Button
v-if="filter?.columnType === '_SEARCH' && isFilterSet(filter)"
@click="clearSearch(filter)"
Expand All @@ -64,6 +65,7 @@ function isAFilterSet(filters) {
</Button>
<VDropdown
:aria-id="ariaId + '_' + index"
:triggers="['hover', 'focus']"
:distance="12"
theme="tooltip"
Expand Down
2 changes: 2 additions & 0 deletions apps/nuxt3-ssr/components/SideModal.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import type { INotificationType } from "~/interfaces/types";
const ariaId = useId();
const props = withDefaults(
defineProps<{
slideInRight?: boolean;
Expand Down Expand Up @@ -81,6 +82,7 @@ const bgClass = computed(() => {

<template>
<VDropdown
:aria-id="ariaId"
:shown="show"
:positioning-disabled="true"
@show="preAnimation()"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import type { HarmonizationIconSize } from "../../interfaces/types";
const ariaId = useId();
const props = withDefaults(
defineProps<{
Expand Down Expand Up @@ -28,7 +29,12 @@ const props = withDefaults(
No data
</li>
</ul>
<VDropdown :triggers="['hover', 'focus']" :distance="12" theme="tooltip">
<VDropdown
:aria-id="ariaId"
:triggers="['hover', 'focus']"
:distance="12"
theme="tooltip"
>
<div class="flex gap-1 text-blue-500 hover:underline cursor-pointer">
<BaseIcon name="info" />
<span> About statuses </span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import type { HarmonizationIconSize } from "../../interfaces/types";
const ariaId = useId();
const props = withDefaults(
defineProps<{
Expand All @@ -24,7 +25,12 @@ const props = withDefaults(
No data
</li>
</ul>
<VDropdown :triggers="['hover', 'focus']" :distance="12" theme="tooltip">
<VDropdown
:aria-id="ariaId"
:triggers="['hover', 'focus']"
:distance="12"
theme="tooltip"
>
<div class="flex gap-1 text-blue-500 hover:underline cursor-pointer">
<BaseIcon name="info" />
<span> About statuses </span>
Expand Down

0 comments on commit b5f364c

Please sign in to comment.