Skip to content

fix(user-onboarding): restore tour button actions - #88

Merged
a-ganguly merged 1 commit into
masterfrom
GH-87
Sep 29, 2026
Merged

a-ganguly merged 1 commit into
masterfrom
GH-87

Conversation

@piyushsinghgaur1

@piyushsinghgaur1 piyushsinghgaur1 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

In @sourceloop/user-onboarding-client, the tour's Next, Previous and custom buttons (e.g. Skip) did nothing when clicked. This PR makes them work again.

How the bug came about

  • shepherd.js expects a button's action to be the click handler itself ((this: Tour) => void) and calls it on click.
  • TourButton.action was typed as () => Step.StepOptionsButton['action'], a function that returns a handler. While the actionAssignment parameters were untyped (any), this mismatch never caused a compile error.
  • The stricter TypeScript 6 checks that came with the Angular 22 upgrade needed explicit types on those parameters. To match the TourButton.action type, the assignments were then wrapped as b.action = () => handler. On click, shepherd.js got the handler back but never ran it.

The fix

  • models/tour-button.ts: type action as Step.StepOptionsButton['action'], which is what shepherd.js actually uses.
  • lib/tour-service.service.ts (actionAssignment): assign the handlers directly again, as before the upgrade, for prevAction, nextAction and custom registered functions.
  • user-onboarding-element/package.json: the element bundle hash, regenerated by the build.

No regression expected

  • actionAssignment is the only place that sets action, so runtime behaviour matches what it was before the Angular 22 upgrade.
  • The type change is compatible for apps: anything that assigns a handler to action still type-checks.
  • Apps that added a local workaround for this (for example, patching actionAssignment to call the returned handler) can remove it after upgrading.

Fixes #87

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • ng build userOnboardingLib succeeds on Angular 22.2.0 / TypeScript 6.0.3.
  • The built bundle assigns the handlers directly, and the published .d.ts has action?: Step.StepOptionsButton['action'].
  • A standalone strict TypeScript 6 check compiles with the corrected type. The previous type still rejects a () => void handler.
  • The pre-commit hook (lerna run test) passes.
  • Manual check in a consuming app: Next / Previous / Skip in a multi-step tour, using a packed build (npm pack from projects/user-onboarding-lib/dist).

Checklist:

  • Performed a self-review of my own code
  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Any dependent changes have been merged and published in downstream modules

- shepherd.js expects a button's `action` to be the click handler itself,
  but `TourButton.action` was typed as a function that returns a handler
- under the stricter TypeScript 6 checks that came with the Angular 22
  upgrade, the handlers in `actionAssignment` were wrapped to match that
  type, so clicking Next, Previous or a custom button returned the handler
  instead of running it
- type `TourButton.action` as `Step.StepOptionsButton['action']` and
  assign the handlers directly again, matching the behaviour from before
  the upgrade
- no regression expected: `actionAssignment` is the only place that sets
  `action`, apps that pass handlers still type-check, and the library
  builds on Angular 22 / TypeScript 6

GH-87
@piyushsinghgaur1 piyushsinghgaur1 self-assigned this Sep 28, 2026
@piyushsinghgaur1 piyushsinghgaur1 added the bug Something isn't working label Sep 28, 2026
@piyushsinghgaur1
piyushsinghgaur1 marked this pull request as ready for review September 28, 2026 11:30
@Akanksha13-dev

Copy link
Copy Markdown
Screen.Recording.2026-09-28.at.5.05.25.PM.mov

working fine

@a-ganguly
a-ganguly merged commit ca62968 into master Sep 29, 2026
2 checks passed
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.

user-onboarding: tour Next/Previous/custom buttons do nothing on click

4 participants