Skip to content

feat: controlled activeId prop and optional haptics - #4

Merged
NagyVikt merged 1 commit into
mainfrom
claude/activeid-haptics
Jun 22, 2026
Merged

feat: controlled activeId prop and optional haptics#4
NagyVikt merged 1 commit into
mainfrom
claude/activeid-haptics

Conversation

@NagyVikt

Copy link
Copy Markdown
Contributor

Second follow-up PR — backward-compatible API ergonomics (#7, #9).

activeId (#7)

Pass the active tab's id once on <MobileTabBar activeId={...}> and each tab's active state is derived internally (tab.id === activeId), so consumers can drop the per-tab isActive booleans. isActive is now optional and still honored when activeId is omitted — existing usage is unchanged.

haptics (#9)

Opt-in haptics prop fires navigator.vibrate(10) on tap for both links and action tabs, guarded for platforms without the Vibration API (no-op on iOS Safari). For links it does not preventDefault, so navigation still happens.

Tests

  • activeId selects the active tab and overrides per-tab isActive; also works with no isActive on any tab.
  • navigator.vibrate is stubbed → called with 10 on tap only when haptics is set; the tab's own onClick still fires.

12 tests total now pass.

Verification

npm run type-check, npm run build, npm test all green locally. README updated (API table, activeId/haptics sections, isActive marked optional).

🤖 Generated with Claude Code

https://claude.ai/code/session_01WCE1RpZpzupe5kvo5aGGvV


Generated by Claude Code

- activeId: pass the active tab's id on <MobileTabBar> and it derives each
  tab's active state internally, so consumers can drop the per-tab isActive
  booleans. isActive is now optional and still honored when activeId is omitted,
  so existing usage is unchanged.
- haptics: opt-in navigator.vibrate(10) on tap (links and action tabs), guarded
  for platforms without the Vibration API; navigation still proceeds for links.
- Tests for both; README documents the props and the now-optional isActive.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WCE1RpZpzupe5kvo5aGGvV
@NagyVikt
NagyVikt marked this pull request as ready for review June 22, 2026 10:34
@NagyVikt
NagyVikt merged commit 723c757 into main Jun 22, 2026
1 check passed
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.

2 participants