Skip to content

fix: rebuild the trigger for a different widget on the same content - #33

Merged
onurhanavci merged 8 commits into
fix/android-left-trigger-fullscreen-widgetfrom
fix/trigger-reuse-widget-id
Oct 27, 2026
Merged

onurhanavci merged 8 commits into
fix/android-left-trigger-fullscreen-widgetfrom
fix/trigger-reuse-widget-id

Conversation

@onurhanavci

Copy link
Copy Markdown
Member

Stacked on #32 (which is on #31). Both SDKs kept the trigger on screen when the next widget had the same content and trigger type, so a second widget on that content never showed its own copy, colors or position.

  • iOS and Android overlay managers now also compare the widget id before reusing the trigger
  • The same widget tracked again (a revisit, or one widget on two screens) still keeps its trigger as it is
  • Android: Robolectric test for both cases; iOS tests run without a window scene, so checked in the example app instead
  • Not changed: an edited widget with the same id still waits for a different widget to rebuild

Test: in the example app with the PoltioDemoAccount key, go straight from Shop (blue card) to TVs; it shows the navy, open card instead of keeping the blue one.

Both overlay managers kept the trigger on screen when the incoming widget
had the same content public_id and trigger type, so two widgets on one
content (say a blue card on home and a navy, open card on another page)
showed whichever was built first. The current widget id now has to match
too; the same widget tracked again still keeps its trigger as it is.
@onurhanavci onurhanavci self-assigned this Oct 27, 2026
@onurhanavci onurhanavci added the bug Something isn't working label Oct 27, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the PoltioOverlayManager on both Android and iOS to distinguish between widgets that share the same content (public ID) and trigger type but have different widget IDs. It introduces a currentWidgetId property and an isCurrent helper method to ensure that triggers are correctly replaced when a different widget ID is encountered. Additionally, a unit test has been added to the Android test suite to verify this behavior. I have no feedback to provide.

@gcg gcg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on the Android emulator (Pixel_10_Pro_XL) and the iOS simulator (iPhone 17 Pro) at c13dc93 with the demo account. Full write-up with before/after screenshots: https://claude.ai/artifact/EM8Pgd7CV3uwmYVrb6vP9F

All four demo screens show the same content through their own widgets (Home/Shop 498, Lookbook 497, Phones 500, TVs 501), so this setup hits the bug directly.

Navigation Before (#32 build) This PR
Home/Shop → TVs Keeps Home's blue card Shows TVs' navy card, open (Android and iOS)
Lookbook → Phones Keeps Lookbook's left box Shows Phones' navy box on the right (Android and iOS)
Phones → Logs → Phones — Keeps the same trigger view (Android)

make test-android 97/97, including the new overlay test. make test-ios 69/69.

Code: no issues. currentWidgetId is cleared everywhere the content id and trigger type are, a response without an id behaves as before, and retries only continue for the same widget.

Worth noting: the bug also credited the wrong widget. The kept trigger reported a view for the new widget, and opening it passed the old widget's id, so widgets that share content were getting each other's views and opens. Worth a line in the release notes.

Already on main, not from this PR (iOS only):

  • The card's Poltio wordmark uses .secondaryLabel (PoltioBrandingMarkView.swift:38), so it's barely readable on a dark card like TVs'. Android uses a fixed grey that stays readable.
  • A bottom-docked box (Phones) sits partly behind the example app's floating tab bar.

- Triggers dock by physical side: left/right anchors on iOS, LEFT/RIGHT
  gravity on Android, so a right-to-left language no longer flips a
  trigger onto the edge its corners aren't drawn for. The widget's close
  button is top-right in every language too. (Poltio/issues#6434)
- iOS: bottom-docked triggers sit above the host app's visible tab bar,
  which the overlay window's safe area can't see; found under child
  controllers too, where SwiftUI's TabView keeps it. (Poltio/issues#6435)
- Android: the widget sheet never hosts the trigger, and with no host
  resumed the widget waits for the next host to resume instead of being
  dropped after 2s of retries; a host rebuilt by a configuration change
  carries its trigger over. (Poltio/issues#6436)
- iOS: the card's Poltio wordmark is light on dark cards and dark on
  light ones, instead of following the system appearance.
  (Poltio/issues#6437)
…widget open

Review of #34 found the trigger attached but invisible after rotating with
the sheet open and closing it. Two causes:

- The kept trigger was shown as the host resumed, and the sheet's dismiss
  callback then ran the entrance animation again. It took the trigger's
  current translation as its resting place, still the 80dp entry offset,
  so the trigger settled off-screen. The entrance now always settles at
  0, and the dismiss callback only restores a trigger the sheet hid.
- A host rebuilt behind the open sheet resumes for a moment and pauses
  again, which attached and counted the trigger under the sheet. The kept
  trigger is now shown from a posted check that the host is still resumed.

A trigger carried over a configuration change is no longer counted again:
a plain rotation counted twice once the host re-tracked its screen.
#34 measured the host tab bar once, when the trigger was built, so a
trigger that stayed up didn't follow the bar hiding
(hidesBottomBarWhenPushed), coming back, or changing height on rotation.
The overlay manager now keeps the bottom constraint and measures the bar
again on the reuse path (after any host transition in flight finishes),
when the overlay window changes size, and when the widget sheet closes.
A new constant also marks the layout stale; without it the next layout
pass kept the old position.
CI failed the rotation test on b5c1276: Robolectric's recreate() drains
the main looper while the rebuilt host is briefly resumed, so the posted
"still resumed?" check ran mid-way and attached the trigger under the
sheet. That check relied on looper timing, not on the sheet being up.

The overlay manager now tracks the widget sheet through the lifecycle
callbacks, open from its creation until it's destroyed for good (a
rotation rebuilding it doesn't count), and shows the kept trigger only
once the sheet is closed and a host is resumed, in either order. The
test helper is inline so a failing assertion reports its own line.
fix(ios): keep bottom triggers clear of the tab bar when it changes
fix: RTL docking, tab bar clearance, rotation and wordmark contrast
@onurhanavci
onurhanavci merged commit 75298cb into fix/android-left-trigger-fullscreen-widget Oct 27, 2026
6 checks passed
@onurhanavci
onurhanavci deleted the fix/trigger-reuse-widget-id branch October 27, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants