Skip to content

Conversation

@umakhanpro
Copy link

Summary

Fixes #4380

The pointercancel event listener was already registered on document in initTabbarHighlight, but the f7ToolbarOnPointer handler had no case for e.type === 'pointercancel'. This caused data.touched to remain true after the pointer sequence was cancelled by the system (e.g., when the app is backgrounded on iOS/Android or a browser tab loses focus).

On resume, the next pointerup anywhere on document would trigger unsetHighlightOnTouch(), which calculates the closest tab from the touch coordinates and calls .click() — switching tabs unintentionally.

Changes

Added a pointercancel handler that:

  • Resets data.touched and data.moved to false
  • Clears data.setTransform
  • Stops the animation frame
  • Removes the tab-link-highlight-pressed CSS class
  • Restores the highlight position to the currently active tab (data.activeIndex) without triggering any click

This mirrors the cleanup logic of pointerup but intentionally skips unsetHighlightOnTouch() to avoid triggering a tab change.

Test Plan

  1. Open a Framework7 app with iOS theme and tabbar using ToolbarPane
  2. Tap a tab, then background the app (or switch browser tabs)
  3. Resume the app (or switch back) and tap anywhere
  4. Verify that no unintended tab switch occurs
  5. Verify that normal tabbar interaction still works correctly after resume

Made with Cursor

…touch state

The pointercancel event listener was registered but not handled in the
f7ToolbarOnPointer callback. When a Capacitor/Cordova app is backgrounded
(or a browser tab loses focus), the OS fires pointercancel to terminate
active pointer sequences. Without handling this event, data.touched remains
true after resume. The next pointerup anywhere on the document then triggers
unsetHighlightOnTouch, which calculates the closest tab link from the touch
coordinates and calls .click() on it — causing an unintended tab switch.

This commit adds a pointercancel handler that resets the touch state
(touched, moved, setTransform), stops the animation, removes the pressed
class, and restores the highlight to the currently active tab position
without triggering any click.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Tabbar highlight: pointercancel not handled, causes unintended tab switch after app resume

1 participant