@arun-dev/headless 4.5.0 → 4.5.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.
@@ -246,8 +246,10 @@ function DialogPopup({ className, children, render, ...rest }) {
246
246
  (0, import_react5.useEffect)(() => {
247
247
  const dialog = elementRef.current;
248
248
  if (!dialog || typeof dialog.showModal !== "function") return;
249
- if (open && !dialog.open) dialog.showModal();
250
- else if (!open && dialog.open) dialog.close();
249
+ if (open && !dialog.open) {
250
+ dialog.showModal();
251
+ if (!dialog.open) setOpen(false);
252
+ } else if (!open && dialog.open) dialog.close();
251
253
  });
252
254
  const element = useRender({
253
255
  render,
@@ -106,8 +106,10 @@ function DialogPopup({ className, children, render, ...rest }) {
106
106
  useEffect(() => {
107
107
  const dialog = elementRef.current;
108
108
  if (!dialog || typeof dialog.showModal !== "function") return;
109
- if (open && !dialog.open) dialog.showModal();
110
- else if (!open && dialog.open) dialog.close();
109
+ if (open && !dialog.open) {
110
+ dialog.showModal();
111
+ if (!dialog.open) setOpen(false);
112
+ } else if (!open && dialog.open) dialog.close();
111
113
  });
112
114
  const element = useRender({
113
115
  render,
@@ -273,6 +273,7 @@ function PopoverPopup({
273
273
  const shown = popup.matches(":popover-open");
274
274
  if (open && !shown) {
275
275
  popup.showPopover({ source: triggerRef.current ?? void 0 });
276
+ if (!popup.matches(":popover-open")) setOpen(false);
276
277
  } else if (!open && shown) popup.hidePopover();
277
278
  });
278
279
  return useRender({
@@ -116,6 +116,7 @@ function PopoverPopup({
116
116
  const shown = popup.matches(":popover-open");
117
117
  if (open && !shown) {
118
118
  popup.showPopover({ source: triggerRef.current ?? void 0 });
119
+ if (!popup.matches(":popover-open")) setOpen(false);
119
120
  } else if (!open && shown) popup.hidePopover();
120
121
  });
121
122
  return useRender({
@@ -325,8 +325,10 @@ function TooltipPopup({
325
325
  const popup = elementRef.current;
326
326
  if (!popup || typeof popup.showPopover !== "function") return;
327
327
  const shown = popup.matches(":popover-open");
328
- if (open && !shown) popup.showPopover();
329
- else if (!open && shown) popup.hidePopover();
328
+ if (open && !shown) {
329
+ popup.showPopover();
330
+ if (!popup.matches(":popover-open")) setOpen(false);
331
+ } else if (!open && shown) popup.hidePopover();
330
332
  });
331
333
  (0, import_react5.useEffect)(() => {
332
334
  if (!open) return;
@@ -168,8 +168,10 @@ function TooltipPopup({
168
168
  const popup = elementRef.current;
169
169
  if (!popup || typeof popup.showPopover !== "function") return;
170
170
  const shown = popup.matches(":popover-open");
171
- if (open && !shown) popup.showPopover();
172
- else if (!open && shown) popup.hidePopover();
171
+ if (open && !shown) {
172
+ popup.showPopover();
173
+ if (!popup.matches(":popover-open")) setOpen(false);
174
+ } else if (!open && shown) popup.hidePopover();
173
175
  });
174
176
  useEffect2(() => {
175
177
  if (!open) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arun-dev/headless",
3
- "version": "4.5.0",
3
+ "version": "4.5.1",
4
4
  "description": "Unstyled React behaviour primitives — render engine, controlled/uncontrolled state, and data-* state projection. Ships no CSS and no class names.",
5
5
  "license": "MIT",
6
6
  "type": "module",