Skip to content

container: preserve user OnTappedBar when MultipleWindows wraps it - #6482

Open
LunatikDG wants to merge 1 commit into
fyne-io:developfrom
LunatikDG:fix/multiplewindows-ontappedbar-overwrite
Open

container: preserve user OnTappedBar when MultipleWindows wraps it#6482
LunatikDG wants to merge 1 commit into
fyne-io:developfrom
LunatikDG:fix/multiplewindows-ontappedbar-overwrite

Conversation

@LunatikDG

Copy link
Copy Markdown
Contributor

Description:

MultipleWindows.setupChild() runs on every refreshChildren() call — i.e. on
Add, RaiseToTop and Refresh — and unconditionally replaced
InnerWindow.OnTappedBar with its own raise-to-top handler. Any callback the
caller had already set on the window (before or after it was added) was
silently discarded, so setting OnTappedBar before the window's first render
never survived.

Fix: capture the existing OnTappedBar once and wrap it (user callback first,
then the built-in raise-to-top), guarded by a private tappedBarWrapped flag
on InnerWindow so repeated Refresh()/Add() calls don't keep re-wrapping
it into an ever-growing closure chain that would call the user's callback
multiple times per tap.

Fixes #6433

Scope note

InnerWindow.OnDragged/OnResized are overwritten by the same setupChild()
in exactly the same way and have the identical latent bug — I left them out of
this PR to keep it scoped to the one reported symptom, and opened #6481 to
track fixing them separately.

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

Where applicable:

  • Public APIs match existing style and have Since: line.
  • Any breaking changes have a deprecation path or have been discussed.
  • Check for binary size increases when importing new modules.

setupChild() ran on every refreshChildren() (Add, RaiseToTop, Refresh)
and unconditionally replaced InnerWindow.OnTappedBar with its own
raise-to-top handler, discarding any callback the caller had already
set. Wrap the existing callback once, guarded by a private flag on
InnerWindow so repeated refreshes don't chain-wrap it.

Fixes fyne-io#6433
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 59.852% (+0.03%) from 59.823% — LunatikDG:fix/multiplewindows-ontappedbar-overwrite into fyne-io:develop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NewMultipleWindows constructor overwrites OnTappedBar callback which may have been user-set

2 participants