Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mount } from "@vue/test-utils";

Check warning on line 1 in packages/component-library/src/components/_internal/mt-floating-ui/mt-floating-ui.spec.ts

View workflow job for this annotation

GitHub Actions / Static Analysis

'@vue/test-utils' import is restricted from being used
import MtFloatingUi from "./mt-floating-ui.vue";
import flushPromises from "flush-promises";

Expand Down Expand Up @@ -117,7 +117,7 @@

expect(document.querySelector("#appWrapper")!.contains(floatingUi)).toBeTruthy(); // won't get teleported, so it's still in the app wrapper
expect(document.querySelector("#appWrapper")!.contains(floatingUiContent)).toBeFalsy(); // will get teleported to the body, so it's outside the app wrapper
expect(floatingUiContent!.parentElement!.tagName).toBe("BODY");
expect(document.body.contains(floatingUiContent)).toBe(true);
});

it("should unmount the floating ui to the document body", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,29 @@
<slot name="trigger" />
</div>
<Teleport to="body">
<div
v-if="isOpened"
ref="floatingUiContent"
v-on-click-outside="onClickOutside"
class="mt-floating-ui__content"
:data-show="isOpened"
tabindex="0"
:style="contentStyles"
>
<Transition name="popoverTransition" appear>
<div
v-if="showArrow"
ref="floatingUiArrow"
class="mt-floating-ui__arrow"
data-popper-arrow
/>

<transition name="popoverTransition">
<template v-if="isOpened">
<slot
:reference-element-width="referenceElementWidth"
:reference-element-height="referenceElementHeight"
/>
</template>
</transition>
</div>
v-if="isOpened"
ref="floatingUiContent"
v-on-click-outside="onClickOutside"
class="mt-floating-ui__content"
:data-show="isOpened"
tabindex="0"
:style="contentStyles"
>
<div
v-if="showArrow"
ref="floatingUiArrow"
class="mt-floating-ui__arrow"
data-popper-arrow
/>

<slot
:reference-element-width="referenceElementWidth"
:reference-element-height="referenceElementHeight"
/>
</div>
</Transition>
</Teleport>
</div>
</template>
Expand Down Expand Up @@ -272,32 +270,24 @@ onBeforeUnmount(() => {
transform: rotate(45deg);
}

&.mt-floating-ui--top,
&.mt-floating-ui--top .mt-popover__content {
transform-origin: top;
}

&.mt-floating-ui--right,
&.mt-floating-ui--right .mt-popover__content {
transform-origin: right;
}

&.mt-floating-ui--bottom,
&.mt-floating-ui--bottom .mt-popover__content {
transform-origin: bottom;
}

&.mt-floating-ui--left,
&.mt-floating-ui--left .mt-popover__content {
transform-origin: left;
}
}

.popoverTransition-enter-active,
.popoverTransition-leave-active {
transition:
transform 0.15s,
opacity 0.15s;
}

.popoverTransition-enter, .popoverTransition-leave-to /* .fade-leave-active below version 2.1.8 */ {
transform: scale3d(1, 0, 1);
opacity: 0;
}
</style>
Loading