all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: yew-devel@lists.proxmox.com
Subject: [PATCH yew-widget-toolkit 4/4] dom: align: fix fallback check for placements
Date: Fri, 17 Jul 2026 14:55:31 +0200	[thread overview]
Message-ID: <20260717125555.2898147-5-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260717125555.2898147-1-d.csapak@proxmox.com>

'try_fit_rect' takes a 'has_fallback' parameter, and it was intended
that this is false only for the last placement in the list.

Since `skip(1)` was done before `enumerate()`, the index was off by one.
Also the index is always smaller than `len()` so we have to compensate
by 1 for that.

Fix this by changing the order of `enumerate` and `skip` so the index is
the 'correct' one, and add +1 before checking against the length.

While at it, reuse `num_placements` instead of calculating the length
again.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/dom/align.rs | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/dom/align.rs b/src/dom/align.rs
index a20cc6e..7d7fea8 100644
--- a/src/dom/align.rs
+++ b/src/dom/align.rs
@@ -480,16 +480,15 @@ where
     );
 
     // try fallback placements if the first one does not fit
-    if options.placements.len() > 1 && !fits(&rect, &window_rect, &options.placements[0].direction)
-    {
-        for (idx, placement) in options.placements.iter().skip(1).enumerate() {
+    if num_placements > 1 && !fits(&rect, &window_rect, &options.placements[0].direction) {
+        for (idx, placement) in options.placements.iter().enumerate().skip(1) {
             let new_rect = try_fit_rect(
                 &base,
                 &element,
                 &window_rect,
                 placement,
                 options.offset,
-                idx < num_placements,
+                idx + 1 < num_placements,
             );
 
             if fits(&new_rect, &window_rect, &placement.direction) {
-- 
2.47.3





  parent reply	other threads:[~2026-07-17 12:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17 12:55 [PATCH yew-widget-toolkit 0/4] small cleanups/fixes Dominik Csapak
2026-07-17 12:55 ` [PATCH yew-widget-toolkit 1/4] widget: form: radio button: fix property comments Dominik Csapak
2026-07-17 12:55 ` [PATCH yew-widget-toolkit 2/4] widget: form: radio button: dim boxlabel when disabled Dominik Csapak
2026-07-17 12:55 ` [PATCH yew-widget-toolkit 3/4] widget: form: radio button: use 'radio' aria role instead of 'checkbox' Dominik Csapak
2026-07-17 12:55 ` Dominik Csapak [this message]
2026-07-17 21:59 ` applied: [PATCH yew-widget-toolkit 0/4] small cleanups/fixes Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260717125555.2898147-5-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=yew-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal