From cee257694447f846b0fb6fb12c21532e088031fd Mon Sep 17 00:00:00 2001
From: Aylur <k.demeter@protonmail.com>
Date: Thu, 23 Jan 2025 23:09:18 +0100
Subject: update popover example #249

---
 examples/gtk3/js/popover/Popover.tsx | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

(limited to 'examples/gtk3/js/popover/Popover.tsx')

diff --git a/examples/gtk3/js/popover/Popover.tsx b/examples/gtk3/js/popover/Popover.tsx
index 29c61e3..38ea01e 100644
--- a/examples/gtk3/js/popover/Popover.tsx
+++ b/examples/gtk3/js/popover/Popover.tsx
@@ -19,9 +19,17 @@ type PopoverProps = Pick<
     onClose?(self: Widget.Window): void
 }
 
+/**
+ * Full screen window widget where you can space the child widget
+ * using margins and alignment properties.
+ *
+ * NOTE: Child widgets will assume they can span across the full window width
+ * this means that setting `wrap` or `ellipsize` on labels for example will not work
+ * without explicitly setting its `max_width_chars` property.
+ * For a workaround see Popover2.tsx
+ */
 export default function Popover({
     child,
-    visible = false,
     marginBottom,
     marginTop,
     marginLeft,
@@ -39,13 +47,7 @@ export default function Popover({
             anchor={TOP | BOTTOM | LEFT | RIGHT}
             exclusivity={Astal.Exclusivity.IGNORE}
             onNotifyVisible={(self) => {
-                // instead of anchoring to all sides we set the width explicitly
-                // otherwise label wrapping won't work correctly without setting their width
-                if (self.visible) {
-                    self.widthRequest = self.get_current_monitor().workarea.width
-                } else {
-                    onClose?.(self)
-                }
+                if (!self.visible) onClose?.(self)
             }}
             // close when click occurs otside of child
             onButtonPressEvent={(self, event) => {
-- 
cgit v1.2.3

