@atlaskit/top-layer 0.3.0 → 0.5.0
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.
- package/CHANGELOG.md +35 -0
- package/dist/cjs/internal/use-anchor-positioning.js +23 -8
- package/dist/cjs/testing/polyfill.js +533 -63
- package/dist/es2019/internal/use-anchor-positioning.js +23 -8
- package/dist/es2019/testing/polyfill.js +543 -63
- package/dist/esm/internal/use-anchor-positioning.js +23 -8
- package/dist/esm/testing/polyfill.js +533 -63
- package/dist/types/testing/polyfill.d.ts +7 -30
- package/dist/types-ts4.5/testing/polyfill.d.ts +7 -30
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @atlaskit/top-layer
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`6e656fce5ceee`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6e656fce5ceee) -
|
|
8
|
+
Fix anchor positioning so multiple popovers can share the same trigger element. Previously the
|
|
9
|
+
second `useAnchorPosition` call on the same trigger would overwrite the first call's `anchor-name`
|
|
10
|
+
style, leaving the first popover unpositioned.
|
|
11
|
+
|
|
12
|
+
## 0.4.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [`58c9d421e96b1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/58c9d421e96b1) -
|
|
17
|
+
Improves the jsdom test polyfill (`testing/polyfill`) to better match WHATWG popover spec
|
|
18
|
+
semantics:
|
|
19
|
+
- Adds the `el.popover` IDL getter/setter so feature-detection (`supportsPopoverHint()` etc) works
|
|
20
|
+
in jsdom and `popover="hint"` is exercised in tests rather than silently falling back to
|
|
21
|
+
`popover="auto"`.
|
|
22
|
+
- Implements a separate hint stack so opening a `hint` does not close open `auto` popovers;
|
|
23
|
+
opening an `auto` closes all hints; light-dismiss and Escape walk both stacks per spec.
|
|
24
|
+
- Implements proper "topmost popover ancestor" lookup that walks both DOM ancestry and the invoker
|
|
25
|
+
chain (via `popovertarget`), so opening a popover from a button inside another popover does not
|
|
26
|
+
close the parent.
|
|
27
|
+
- Light-dismiss now uses pointerdown + pointerup (with `mousedown` + `mouseup` fallback) and a
|
|
28
|
+
same-target check so drag-out and drag-in gestures do not dismiss popovers.
|
|
29
|
+
- `togglePopover()` now returns the actual resulting open state.
|
|
30
|
+
- Per-method patching (`showPopover` / `hidePopover` / `togglePopover`) so partial native support
|
|
31
|
+
in future jsdom versions still patches the missing methods.
|
|
32
|
+
- Disconnected popovers are pruned from the open stacks (defends against test-pollution).
|
|
33
|
+
- Clears any inline `opacity: 0` set by callers (such as `use-anchor-positioning`'s
|
|
34
|
+
"hide-until-measured" guard) once the open toggle fires, since jsdom does not deliver
|
|
35
|
+
`ResizeObserver` callbacks.
|
|
36
|
+
- Treats `popover=""` (empty value) as `auto` per spec.
|
|
37
|
+
|
|
3
38
|
## 0.3.0
|
|
4
39
|
|
|
5
40
|
### Minor Changes
|
|
@@ -234,7 +234,6 @@ function useAnchorPosition(_ref5) {
|
|
|
234
234
|
forceFallbackPositioning = _ref5$forceFallbackPo === void 0 ? false : _ref5$forceFallbackPo,
|
|
235
235
|
arrow = _ref5.arrow;
|
|
236
236
|
var id = (0, _react.useId)();
|
|
237
|
-
var anchorName = "--anchor-".concat(id.replace(/:/g, ''));
|
|
238
237
|
(0, _react.useLayoutEffect)(function () {
|
|
239
238
|
var trigger = anchorRef.current;
|
|
240
239
|
var popover = popoverRef.current;
|
|
@@ -248,6 +247,9 @@ function useAnchorPosition(_ref5) {
|
|
|
248
247
|
var crossAxisShiftCssValue = resolvedPlacement.offset.crossAxisShift.value;
|
|
249
248
|
var shouldForceFallback = Boolean(forceFallbackPositioning);
|
|
250
249
|
if (supportsAnchorPositioning() && !shouldForceFallback) {
|
|
250
|
+
// Reuse an existing `anchor-name` if the element already has one.
|
|
251
|
+
// Another popover might already be anchored to the old name.
|
|
252
|
+
var anchorName = trigger.style.getPropertyValue('anchor-name') || "--anchor-".concat(id.replace(/:/g, ''));
|
|
251
253
|
var gap = edgeMargin({
|
|
252
254
|
placement: resolvedPlacement,
|
|
253
255
|
offset: gapCssValue
|
|
@@ -345,13 +347,26 @@ function useAnchorPosition(_ref5) {
|
|
|
345
347
|
// because that's where useAnchorPosition sets the margin gap.
|
|
346
348
|
popover.setAttribute('data-ds-popover-arrow', '');
|
|
347
349
|
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* **We are never cleaning up anchor names**
|
|
353
|
+
*
|
|
354
|
+
* _Rationale_
|
|
355
|
+
*
|
|
356
|
+
* - Multiple popovers can share the same anchor element.
|
|
357
|
+
* - Sometimes the `useAnchorPosition` hook and `Popover`
|
|
358
|
+
* are not in the same component.
|
|
359
|
+
* - There can be times when, even with reference counting, we
|
|
360
|
+
* could remove the anchor-name while it's still being used
|
|
361
|
+
* by something else - especially with async react updates
|
|
362
|
+
* which can cause tearing
|
|
363
|
+
*
|
|
364
|
+
* _More_
|
|
365
|
+
*
|
|
366
|
+
* See `notes/decisions/anchor-name-lifetime.md`
|
|
367
|
+
*/
|
|
368
|
+
trigger.style.setProperty('anchor-name', anchorName);
|
|
348
369
|
var _undoPositioning = (0, _combine.combine)((0, _setStyle.setStyle)({
|
|
349
|
-
el: trigger,
|
|
350
|
-
styles: [{
|
|
351
|
-
property: 'anchor-name',
|
|
352
|
-
value: anchorName
|
|
353
|
-
}]
|
|
354
|
-
}), (0, _setStyle.setStyle)({
|
|
355
370
|
el: popover,
|
|
356
371
|
styles: popoverStyles
|
|
357
372
|
}), arrow ? function () {
|
|
@@ -483,5 +498,5 @@ function useAnchorPosition(_ref5) {
|
|
|
483
498
|
popover.style.removeProperty('opacity');
|
|
484
499
|
});
|
|
485
500
|
return undoPositioning;
|
|
486
|
-
}, [anchorRef, popoverRef, placement,
|
|
501
|
+
}, [anchorRef, popoverRef, placement, forceFallbackPositioning, arrow, id]);
|
|
487
502
|
}
|