Skip to content

Commit 45e7589

Browse files
committed
Improvel tooltip placement
1 parent ec4c623 commit 45e7589

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/ruby_ui/tooltip/tooltip_controller.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Controller } from "@hotwired/stimulus";
2-
import { computePosition, autoUpdate, offset } from "@floating-ui/dom";
2+
import { computePosition, autoUpdate, offset, shift } from "@floating-ui/dom";
33

44
export default class extends Controller {
55
static targets = ["trigger", "content"];
@@ -24,7 +24,10 @@ export default class extends Controller {
2424

2525
setFloatingElement() {
2626
this.cleanup = autoUpdate(this.triggerTarget, this.contentTarget, () => {
27-
computePosition(this.triggerTarget, this.contentTarget, { placement: this.placementValue, middleware: [offset(4)] }).then(({ x, y }) => {
27+
computePosition(this.triggerTarget, this.contentTarget, {
28+
placement: this.placementValue,
29+
middleware: [offset(4), shift()]
30+
}).then(({ x, y }) => {
2831
Object.assign(this.contentTarget.style, {
2932
left: `${x}px`,
3033
top: `${y}px`,

0 commit comments

Comments
 (0)