playbook_ui 16.7.0.pre.alpha.play2924tooltipmisalignment16199 → 16.7.0.pre.alpha.play2924tooltipmisalignment16200
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +1 -3
- data/app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx +55 -1
- data/dist/chunks/_typeahead-BS6zjptk.js +5 -0
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +2 -2
- data/dist/chunks/_typeahead-Ce7lXdAg.js +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd1098414a7534b24fca41a8ffeffd3acf6a7a1f48e835bbd318c7a17a42ff1e
|
|
4
|
+
data.tar.gz: 4b5eabe98006633e85de5678573ff1a1a58c3b79fda27d1edbee1cb93af27fd3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba8a28d2434fdca87f08fae27a2c20143adb0734b7553b93c7732fe59c41c6f0320e095725bd64d8e38dbe169761483d4e2c8134a799a5f40b5bce3f615e188b
|
|
7
|
+
data.tar.gz: '0270209c6293af2cf5133bf9530998ed0a0199ecd060fe257b521808531045928da31cb41cda3fd47d718624e7c490d6854faa9b075bd2291db6b96c58fbb11f'
|
|
@@ -86,7 +86,7 @@ const Tooltip = forwardRef((props: TooltipProps, ref: ForwardedRef<unknown>): Re
|
|
|
86
86
|
|
|
87
87
|
const {
|
|
88
88
|
context,
|
|
89
|
-
middlewareData: { arrow: {
|
|
89
|
+
middlewareData: { arrow: { x: arrowX, y: arrowY } = {}, },
|
|
90
90
|
placement,
|
|
91
91
|
refs,
|
|
92
92
|
strategy,
|
|
@@ -144,7 +144,6 @@ const Tooltip = forwardRef((props: TooltipProps, ref: ForwardedRef<unknown>): Re
|
|
|
144
144
|
top: "bottom",
|
|
145
145
|
}[placement.split("-")[0]]
|
|
146
146
|
const arrowPlacementStyle = staticSide ? { [staticSide]: "-5px" } : {}
|
|
147
|
-
const shouldHideArrow = centerOffset !== 0
|
|
148
147
|
|
|
149
148
|
const tooltipSizing = () => {
|
|
150
149
|
return Object.assign(
|
|
@@ -217,7 +216,6 @@ const Tooltip = forwardRef((props: TooltipProps, ref: ForwardedRef<unknown>): Re
|
|
|
217
216
|
className="arrow_bg"
|
|
218
217
|
ref={arrowRef}
|
|
219
218
|
style={{
|
|
220
|
-
opacity: shouldHideArrow ? 0 : 1,
|
|
221
219
|
position: "absolute",
|
|
222
220
|
left: arrowX != null ? `${arrowX}px` : "",
|
|
223
221
|
top: arrowY != null ? `${arrowY}px` : "",
|
|
@@ -2,6 +2,17 @@ import React from "react";
|
|
|
2
2
|
import { cleanup, render, screen, fireEvent, waitFor } from "../utilities/test-utils";
|
|
3
3
|
import { Button, Tooltip } from "playbook-ui";
|
|
4
4
|
|
|
5
|
+
jest.mock("@floating-ui/react", () => {
|
|
6
|
+
const actual = jest.requireActual("@floating-ui/react")
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
...actual,
|
|
10
|
+
useFloating: jest.fn(actual.useFloating),
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const { useFloating } = require("@floating-ui/react")
|
|
15
|
+
|
|
5
16
|
function TooltipTest() {
|
|
6
17
|
const text = "this is a text",
|
|
7
18
|
placement = "top",
|
|
@@ -131,4 +142,47 @@ test("doesn't display tooltip with showTooltip set to false", async () => {
|
|
|
131
142
|
})
|
|
132
143
|
|
|
133
144
|
cleanup();
|
|
134
|
-
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test("keeps the arrow visible when placement flips left with center offset", async () => {
|
|
148
|
+
const actual = jest.requireActual("@floating-ui/react")
|
|
149
|
+
|
|
150
|
+
useFloating.mockImplementationOnce((options) => {
|
|
151
|
+
const result = actual.useFloating(options)
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
...result,
|
|
155
|
+
middlewareData: {
|
|
156
|
+
...result.middlewareData,
|
|
157
|
+
arrow: {
|
|
158
|
+
centerOffset: 12,
|
|
159
|
+
x: 6,
|
|
160
|
+
y: 10,
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
open: true,
|
|
164
|
+
placement: "left",
|
|
165
|
+
x: 20,
|
|
166
|
+
y: 30,
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
render(
|
|
171
|
+
<Tooltip
|
|
172
|
+
data={{ testid: "left-placement-arrow-test" }}
|
|
173
|
+
forceOpenTooltip
|
|
174
|
+
placement="left"
|
|
175
|
+
text="left placement"
|
|
176
|
+
zIndex="10"
|
|
177
|
+
>
|
|
178
|
+
<Button text="hover me" />
|
|
179
|
+
</Tooltip>
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
const tooltip = await screen.findByRole("tooltip")
|
|
183
|
+
const arrow = tooltip.querySelector(".arrow_bg")
|
|
184
|
+
|
|
185
|
+
expect(tooltip).toHaveAttribute("data-placement", "left")
|
|
186
|
+
expect(arrow).toBeInTheDocument()
|
|
187
|
+
expect(arrow).not.toHaveStyle({ opacity: "0" })
|
|
188
|
+
})
|