@jsenv/dom 0.17.0 → 0.17.1

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.
Files changed (2) hide show
  1. package/dist/jsenv_dom.js +29 -8
  2. package/package.json +1 -1
package/dist/jsenv_dom.js CHANGED
@@ -4592,13 +4592,6 @@ const DEFAULT_BEHAVIORS = [
4592
4592
  },
4593
4593
  // no fallback: only claims Tab, other keys continue to next entries
4594
4594
  },
4595
- {
4596
- // Escape natively dismisses only <dialog> elements
4597
- test: (el) => el.tagName === "DIALOG" || Boolean(el.closest("dialog")),
4598
- keys: {
4599
- escape: "dismiss",
4600
- },
4601
- },
4602
4595
  {
4603
4596
  test: (el) => el.matches("input[type='radio'], input[type='checkbox']"),
4604
4597
  keys: {
@@ -4748,6 +4741,18 @@ const DEFAULT_BEHAVIORS = [
4748
4741
  enter: "activate",
4749
4742
  },
4750
4743
  },
4744
+ {
4745
+ // Escape natively dismisses only <dialog> elements. Deliberately late in
4746
+ // the list: the focused element gets first claim on Escape, because the
4747
+ // browser resolves the close request innermost-first. A non-empty
4748
+ // <input type="search"> inside a dialog consumes the first Escape to clear
4749
+ // itself and only a second one reaches the dialog — reporting "dismiss"
4750
+ // here would let our own Escape-to-close shortcuts fire on the first press.
4751
+ test: (el) => el.tagName === "DIALOG" || Boolean(el.closest("dialog")),
4752
+ keys: {
4753
+ escape: "dismiss",
4754
+ },
4755
+ },
4751
4756
  {
4752
4757
  // Non-interactive elements: browser scrolls on Space and arrow keys
4753
4758
  test: () => true,
@@ -11568,6 +11573,10 @@ const MIN_CONTENT_VISIBILITY_RATIO = 0.6;
11568
11573
  *
11569
11574
  * A bit like https://tetherjs.dev/ but different
11570
11575
  */
11576
+ // The event type observeSize() reports with — recognized by check() as "the
11577
+ // change is in another element, not in the tracked rect".
11578
+ const OBSERVED_ELEMENT_SIZE_CHANGE = "observed_element_size_change";
11579
+
11571
11580
  const visibleRectEffect = (
11572
11581
  element,
11573
11582
  update,
@@ -11810,6 +11819,18 @@ const visibleRectEffect = (
11810
11819
  });
11811
11820
  };
11812
11821
 
11822
+ // An observeSize() delivery reports a size change in some *other*
11823
+ // element — this one's own rect and the viewport are both typically
11824
+ // untouched by it, so the dedup below would skip every single one,
11825
+ // defeating the whole point of observeSize (a popover reconsidering its
11826
+ // placement once its own content shrinks/grows, a callout re-measuring
11827
+ // against its message body).
11828
+ if (event.type === OBSERVED_ELEMENT_SIZE_CHANGE) {
11829
+ lastVisibleRect = visibleRect;
11830
+ lastViewportRect = viewportRect;
11831
+ notify();
11832
+ return;
11833
+ }
11813
11834
  const visibleRectChanged =
11814
11835
  !lastVisibleRect ||
11815
11836
  lastVisibleRect.left !== visibleRect.left ||
@@ -12214,7 +12235,7 @@ const visibleRectEffect = (
12214
12235
  pendingFrame = requestAnimationFrame(() => {
12215
12236
  pendingFrame = null;
12216
12237
  check(
12217
- new CustomEvent("observed_element_size_change", {
12238
+ new CustomEvent(OBSERVED_ELEMENT_SIZE_CHANGE, {
12218
12239
  detail: { width, height },
12219
12240
  }),
12220
12241
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/dom",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "type": "module",
5
5
  "description": "DOM utilities for writing frontend code",
6
6
  "repository": {