Skip to content

[Call node] Add support for href with action - #16

Merged
ThaminduDilshan merged 1 commit into
thunder-id:mainfrom
ThaminduDilshan:call-node-rich-text-action
Jul 4, 2026
Merged

[Call node] Add support for href with action#16
ThaminduDilshan merged 1 commit into
thunder-id:mainfrom
ThaminduDilshan:call-node-rich-text-action

Conversation

@ThaminduDilshan

@ThaminduDilshan ThaminduDilshan commented Jul 3, 2026

Copy link
Copy Markdown
Member

Purpose

This pull request introduces support for optional action wiring on rich-text components in embedded flows, allowing specific anchor tags within sanitized HTML to trigger flow actions. The changes include new TypeScript interfaces, enhancements to the React component for handling these actions, and comprehensive unit tests to ensure correct behavior.

Approach

Embedded Flow Model Enhancements:

  • Added a new EmbeddedFlowComponentAction interface to represent optional actions that can be wired to otherwise passive components, such as RICH_TEXT. This enables anchor tags with a data-action-ref attribute to dispatch flow actions.
  • Updated the EmbeddedFlowComponent interface to include an optional action property, allowing components to specify action wiring.
  • Exported the new EmbeddedFlowComponentAction type from the main JavaScript package entry point.

React Component Updates:

  • Modified AuthOptionFactory.tsx to handle the new action property on rich-text components. It now intercepts clicks on sentinel-marked anchors, dispatching a synthetic action with the correct event type and validation semantics. [1] [2]

Testing:

  • Added unit tests for both the model and React component logic, covering various cases such as default event types, validation bypass, correct anchor matching, and fallback behavior when no sentinel anchors are present. [1] [2]

Related Issues

Related PRs

  • N/A

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
  • Tests provided. (Add links if there are any)
    • Unit Tests
    • Integration Tests
  • Breaking changes. (Fill if applicable)
    • Breaking changes section filled.
    • breaking change label added.

Security checks

  • Followed secure coding standards in WSO2 Secure Coding Guidelines
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

Summary by CodeRabbit

  • New Features

    • Added rich-text action link wiring for embedded flows, enabling specific links to dispatch configured flow actions.
    • Exposed the new EmbeddedFlowComponentAction type for consistent use across the library.
  • Bug Fixes

    • Improved rich-text link click interception and dispatch rules, including sentinel-marked anchors, nested click targets, and safe handling when no submit handler is provided.
  • Tests

    • Added Vitest coverage for embedded-flow action behavior and rich-text action-link interaction scenarios.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ThaminduDilshan, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 54 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7f4cd8f9-7f97-423a-9eb8-d8d17ab09a9c

📥 Commits

Reviewing files that changed from the base of the PR and between b2950ff and 3ca1fcc.

📒 Files selected for processing (5)
  • packages/javascript/src/index.ts
  • packages/javascript/src/models/__tests__/embedded-flow.test.ts
  • packages/javascript/src/models/embedded-flow.ts
  • packages/react/src/components/presentation/auth/AuthOptionFactory.tsx
  • packages/react/src/components/presentation/auth/__tests__/AuthOptionFactory.test.tsx
📝 Walkthrough

Walkthrough

Adds an EmbeddedFlowComponentAction model to the JavaScript SDK, re-exports it, wires RichText anchor clicks in AuthOptionFactory to submit a synthesized Action, and adds tests for the model and click behavior.

Changes

Embedded Flow Action Wiring

Layer / File(s) Summary
EmbeddedFlowComponentAction model and export
packages/javascript/src/models/embedded-flow.ts, packages/javascript/src/index.ts, packages/javascript/src/models/__tests__/embedded-flow.test.ts
Adds EmbeddedFlowComponentAction, extends EmbeddedFlowComponent with optional action, re-exports the new type, and adds tests for action shape and RichText optionality.
RichText anchor click dispatch in AuthOptionFactory
packages/react/src/components/presentation/auth/AuthOptionFactory.tsx
Adds RichText click handling that resolves anchor targets, matches data-action-ref, prevents navigation, derives validation skipping from eventType, and calls options.onSubmit with a synthesized Action.
AuthOptionFactory click handling tests
packages/react/src/components/presentation/auth/__tests__/AuthOptionFactory.test.tsx
Adds coverage for sentinel matching, ancestor traversal, fallback binding, Trigger versus Submit behavior, and the no-op path when onSubmit is missing.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant RichTextContainer
  participant AuthOptionFactory
  participant OnSubmitCallback

  User->>RichTextContainer: click anchor element
  RichTextContainer->>AuthOptionFactory: click event bubbles to handler
  AuthOptionFactory->>AuthOptionFactory: resolve anchor and data-action-ref
  AuthOptionFactory->>AuthOptionFactory: prevent default and build formData
  AuthOptionFactory->>OnSubmitCallback: onSubmit(synthesized Action, formData)
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is related to the main change, but it is a bit terse and less specific than the implementation details.
Description check ✅ Passed The description follows the required template and covers purpose, approach, issues, PRs, checklist, and security sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
packages/react/src/components/presentation/auth/__tests__/AuthOptionFactory.test.tsx (1)

24-29: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

richTextWithLink accepts a loosely-typed inline action shape instead of EmbeddedFlowComponentAction.

action?: {ref: string; eventType?: string} duplicates the shape of the exported EmbeddedFlowComponentAction model instead of importing and reusing it. Minor drift risk if the model changes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/react/src/components/presentation/auth/__tests__/AuthOptionFactory.test.tsx`
around lines 24 - 29, The rich text test helper is duplicating the inline action
shape instead of using the shared model type. Update richTextWithLink in
AuthOptionFactory.test.tsx to import and use EmbeddedFlowComponentAction for the
action parameter, keeping its signature aligned with EmbeddedFlowComponent and
avoiding type drift if the model changes.
packages/react/src/components/presentation/auth/AuthOptionFactory.tsx (1)

561-564: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate formData-building loop.

This loop that copies formValues into formData duplicates the identical logic in the Action case's handleClick (Lines 309-313). Consider extracting a small shared helper (e.g. buildFormData(formValues)) to avoid drift between the two copies.

♻️ Proposed helper extraction
+const buildFormDataFromValues = (formValues: Record<string, string>): Record<string, string> => {
+  const formData: Record<string, string> = {};
+  Object.keys(formValues).forEach((field: string) => {
+    formData[field] = formValues[field];
+  });
+  return formData;
+};
+
 const createAuthComponentFromFlow = (
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/react/src/components/presentation/auth/AuthOptionFactory.tsx` around
lines 561 - 564, The formData copy loop in AuthOptionFactory is duplicated and
should be centralized to avoid drift between the Action case and the current
path. Extract the shared Object.keys(formValues) -> formData mapping into a
small helper such as buildFormData(formValues), then call that helper from both
handleClick and the other form submission flow so there is only one
implementation to maintain.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/react/src/components/presentation/auth/AuthOptionFactory.tsx`:
- Around line 570-577: Sentinel anchors handled by AuthOptionFactory’s rich text
click delegation are not keyboard-accessible when they lack href, so the current
eslint-disable justification is incorrect. Update the anchor authoring/handling
contract in AuthOptionFactory so sentinel anchors are either required to include
a non-empty href (or another keyboard-accessible default) or are made focusable
and operable with keyboard handlers in addition to onClick. Use the rich-text
click path and its sentinel-anchor detection logic in AuthOptionFactory to
locate the fix.
- Around line 527-568: The rich text click fallback in AuthOptionFactory’s
handleRichTextClick currently hijacks every anchor when no data-action-ref
sentinel is present. Tighten the fallback so it only dispatches the action in
unambiguous cases, such as when the container has exactly one anchor, and
otherwise ignore the click unless the anchor’s data-action-ref matches
richTextAction.ref. Update the related tests that currently expect “binds to any
anchor when no sentinel-marked anchor exists” to cover the safer behavior.

---

Nitpick comments:
In
`@packages/react/src/components/presentation/auth/__tests__/AuthOptionFactory.test.tsx`:
- Around line 24-29: The rich text test helper is duplicating the inline action
shape instead of using the shared model type. Update richTextWithLink in
AuthOptionFactory.test.tsx to import and use EmbeddedFlowComponentAction for the
action parameter, keeping its signature aligned with EmbeddedFlowComponent and
avoiding type drift if the model changes.

In `@packages/react/src/components/presentation/auth/AuthOptionFactory.tsx`:
- Around line 561-564: The formData copy loop in AuthOptionFactory is duplicated
and should be centralized to avoid drift between the Action case and the current
path. Extract the shared Object.keys(formValues) -> formData mapping into a
small helper such as buildFormData(formValues), then call that helper from both
handleClick and the other form submission flow so there is only one
implementation to maintain.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a09ed46b-20d7-455f-95ed-a892e77479ab

📥 Commits

Reviewing files that changed from the base of the PR and between 354ff39 and f87ed06.

📒 Files selected for processing (5)
  • packages/javascript/src/index.ts
  • packages/javascript/src/models/__tests__/embedded-flow.test.ts
  • packages/javascript/src/models/embedded-flow.ts
  • packages/react/src/components/presentation/auth/AuthOptionFactory.tsx
  • packages/react/src/components/presentation/auth/__tests__/AuthOptionFactory.test.tsx

brionmario
brionmario previously approved these changes Jul 4, 2026
@ThaminduDilshan
ThaminduDilshan force-pushed the call-node-rich-text-action branch from b2950ff to 3ca1fcc Compare July 4, 2026 09:01
@ThaminduDilshan
ThaminduDilshan merged commit fe750f4 into thunder-id:main Jul 4, 2026
3 checks 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