Skip to content

[MODIFIED] consent component, added tooltip#38

Open
zesu22 wants to merge 5 commits into
thunder-id:mainfrom
Infosys:feature/update_consent
Open

[MODIFIED] consent component, added tooltip#38
zesu22 wants to merge 5 commits into
thunder-id:mainfrom
Infosys:feature/update_consent

Conversation

@zesu22

@zesu22 zesu22 commented Jul 27, 2026

Copy link
Copy Markdown

Purpose

resolves thunder-id/thunderid#4279

Summary

Improves the Consent component by adding bulk selection capabilities and attribute tooltips, while cleaning up redundant UI elements.

Changes

  • Added Master Switch: Included a global toggle/checkbox to allow users to select/deselect all optional attributes at once.
  • Added Info Tooltips: Added an info icon button to attributes that displays helpful details about optional and essential consent items on hover.
  • Configurable Props: Updated the Consent component props to accept a config object for dynamically passing custom labels and tooltip data for both essential and optional attributes.
  • Code Cleanup: Removed an unnecessary Divider component from inside ConsentCheckboxList.

Approach

  1. Prop Extension (ConsentProps):

    • Added config: Record<string, unknown> to ConsentProps to flexibly pass label text and tooltip metadata for both essential and optional attributes.
  2. Master Switch Implementation:

    • Introduced a toggle button above optional attributes that acts as a global master switch to enable or disable all optional attributes in a single action.
  3. Reusable Tooltip System:

    • Built a custom Tooltip component accepting children (e.g., an HTML element or React node), className, helperText, and position (top | bottom | left | right).

    • Integrated an Info Icon into the label layout of essential and optional attributes to trigger the tooltip on hover.

  4. Styling & Cleanup:

    • Updated local CSS for layout adjustments around the info icon and master switch.

    • Cleaned up the JSX structure by removing an unnecessary Divider component inside ConsentCheckboxList.

Related Issues

  • N/A

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 customizable essential/optional consent section labels with optional info tooltips.
    • Added a master toggle to select/clear optional consent attributes.
    • Enhanced tooltips with placement support, improved keyboard/focus behavior, and ariaLabel.
    • Re-exported PromptElement type for embedded flow usage.
  • Bug Fixes
    • Optional consent items now default to unchecked when no saved value exists.
    • Essential consent now shows a clear “Required” label.
    • Optional consent approval now requires the stored value to be exactly 'true'.
  • Style
    • Improved spacing between consent checkbox list items.

Signed-off-by: Zeeshan Mehboob <zeeshan.mehboob@infosys.com>
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Consent now supports configurable labels, contextual tooltips, optional-attribute master toggles, explicit opt-in defaults, updated essential-item presentation, and stricter consent decisions. A reusable accessible Tooltip primitive, public type re-export, and ignore patterns were also added.

Changes

Consent customization

Layer / File(s) Summary
Tooltip primitive
packages/react/src/components/primitives/Tooltip/*
Adds a keyboard- and focus-accessible Tooltip with configurable placement, helper text, directional arrows, ARIA wiring, and themed Emotion styles.
Consent configuration and master toggle
packages/react/src/components/adapters/Consent.tsx, packages/react/src/components/presentation/auth/AuthOptionFactory.tsx
Passes consent configuration into Consent, renders configurable labels and help tooltips, and adds a master toggle for optional attributes.
Consent item defaults and presentation
packages/react/src/components/adapters/ConsentCheckboxList.tsx, packages/react/src/components/adapters/ConsentCheckboxList.styles.ts
Defaults missing optional values to unchecked, displays “Required” for essential attributes, removes dividers, and adds list-item spacing.
Consent decision handling
packages/react/src/components/presentation/auth/AuthOptionFactory.tsx, packages/vue/src/components/auth/sign-in/AuthOptionFactoryCore.ts
Requires optional consent values to be exactly 'true' for approval when the action is not a deny.

Public and repository updates

Layer / File(s) Summary
Public type and tooling updates
packages/javascript/src/index.ts, .gitignore
Re-exports PromptElement and ignores .nx, __tests__, and .vitest-attachments paths.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AuthOptionFactory
  participant Consent
  participant Tooltip
  participant ConsentCheckboxList
  AuthOptionFactory->>Consent: Pass consent configuration
  Consent->>Tooltip: Render section info tooltip
  Consent->>ConsentCheckboxList: Render consent attributes
  Consent->>ConsentCheckboxList: Apply optional master-toggle value
  ConsentCheckboxList-->>AuthOptionFactory: Submit exact optional consent values
Loading
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Most linked-issue tasks are covered, but the master switch summary doesn't mention the required indeterminate state for partial optional selection. Update the master switch to reflect partial optional-attribute selection with an indeterminate state, and document that behavior.
Out of Scope Changes check ⚠️ Warning The PR also changes .gitignore and exports PromptElement in the JavaScript package, which are unrelated to the consent UI issue. Remove unrelated .gitignore and PromptElement export changes unless they are needed for the consent feature.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly describes the main consent-component and tooltip update.
Description check ✅ Passed The PR description follows the template with Purpose, Approach, related sections, checklist, and security checks filled in.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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: 7

🤖 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 @.gitignore:
- Line 154: Remove the global __tests__ entry from .gitignore so test
directories under packages/*/src/**/__tests__ can be tracked. If ignoring
generated artifacts is still required, replace it with a narrowly scoped path
targeting only those artifacts.

In `@packages/react/src/components/adapters/Consent.tsx`:
- Around line 202-206: Add an accessible name to the master consent Toggle in
the Consent component by providing an aria-label that clearly identifies it as
selecting all optional attributes for the associated purpose, using the existing
purpose context to keep the name specific.
- Around line 80-100: Update the Consent component’s config handling to merge
supplied values with defaultConfig so unspecified labels retain their defaults.
In the tooltip-rendering logic for both essential and optional attributes,
render the info icon only when the resolved label is a non-empty string,
preventing empty help tooltips.
- Line 24: Update the PromptElement import in Consent.tsx to use the public
`@thunderid/javascript` or `@thunderid/browser` export, or an existing project
re-export, instead of the internal dist/models/embedded-flow path. Preserve the
existing PromptElement usage and select the public source that exposes this
type.

In `@packages/react/src/components/adapters/ConsentCheckboxList.tsx`:
- Around line 131-132: Update the optional consent serialization in
AuthOptionFactory so missing values are submitted as declined, matching
ConsentCheckboxList’s unchecked display state. In the relevant submission
predicate, require the value to equal 'true' rather than treating every value
except 'false' as approved.

In `@packages/react/src/components/primitives/Tooltip/Tooltip.tsx`:
- Around line 50-54: Update the Tooltip component’s trigger behavior around the
tooltip container so it is focusable and opens on keyboard focus as well as
mouse hover. Add appropriate ARIA semantics linking the trigger to the tooltip
content, and ensure keyboard interaction can dismiss it while preserving the
existing hover behavior.
- Around line 28-70: Update Tooltiprops and Tooltip to use div-compatible HTML
attributes, set position to default to 'bottom', and apply style plus ...rest to
the rendered container div. Ensure all position-based class lookups use the
resolved default so omitted positioning does not produce an undefined-arrow
class.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 970dd27f-77da-4734-99fc-1e3f8d2c0da0

📥 Commits

Reviewing files that changed from the base of the PR and between 0d057c0 and 5f02f79.

📒 Files selected for processing (7)
  • .gitignore
  • packages/react/src/components/adapters/Consent.tsx
  • packages/react/src/components/adapters/ConsentCheckboxList.styles.ts
  • packages/react/src/components/adapters/ConsentCheckboxList.tsx
  • packages/react/src/components/presentation/auth/AuthOptionFactory.tsx
  • packages/react/src/components/primitives/Tooltip/Tooltip.styles.ts
  • packages/react/src/components/primitives/Tooltip/Tooltip.tsx

Comment thread .gitignore Outdated
Comment thread packages/react/src/components/adapters/Consent.tsx Outdated
Comment thread packages/react/src/components/adapters/Consent.tsx
Comment thread packages/react/src/components/adapters/Consent.tsx
Comment thread packages/react/src/components/adapters/ConsentCheckboxList.tsx
Comment thread packages/react/src/components/primitives/Tooltip/Tooltip.tsx
Comment thread packages/react/src/components/primitives/Tooltip/Tooltip.tsx
@brionmario

Copy link
Copy Markdown
Member

@zesu22 Can we check whether the Coderabbit comments are valid?

Signed-off-by: Zeeshan Mehboob <zeeshan.mehboob@infosys.com>

@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 (1)
packages/react/src/components/presentation/auth/AuthOptionFactory.tsx (1)

397-397: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Add regression tests for optional-consent serialization.

Line 397 changes privacy-sensitive output. Cover missing, 'false', and 'true' values on approve actions, plus a deny action with 'true', to prevent optional attributes being unintentionally approved or rejected.

🤖 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` at
line 397, Add regression tests for the optional-consent serialization around
AuthOptionFactory, covering approve actions with missing, 'false', and 'true'
optional values, plus a deny action with 'true'. Assert that the serialized
approved value matches the expected privacy behavior for each case.
🤖 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/primitives/Tooltip/Tooltip.tsx`:
- Around line 45-53: Update the Tooltip component’s props destructuring in
packages/react/src/components/primitives/Tooltip/Tooltip.tsx:45-53 to provide
defaults for className, helperText, and children. Update the Consent component’s
props destructuring in
packages/react/src/components/adapters/Consent.tsx:105-114 to provide defaults
for suppliedConfig and children, using the repository-approved pattern
consistently so both components satisfy the default-props ESLint rule.

In `@packages/vue/src/components/auth/sign-in/AuthOptionFactoryCore.ts`:
- Line 236: Resolve the unsafe types in the mapping that computes approved
consent values before calling getConsentOptionalKey: type
ConsentPromptData.purposes and its optional elements, or narrow/validate them
before use, so p.purposeId and e.name are statically valid string/number and
string arguments. Update the surrounding consent mapping rather than suppressing
the ESLint errors with any.

---

Nitpick comments:
In `@packages/react/src/components/presentation/auth/AuthOptionFactory.tsx`:
- Line 397: Add regression tests for the optional-consent serialization around
AuthOptionFactory, covering approve actions with missing, 'false', and 'true'
optional values, plus a deny action with 'true'. Assert that the serialized
approved value matches the expected privacy behavior for each case.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4a81a233-0c71-4782-b2c6-ec34ea025eea

📥 Commits

Reviewing files that changed from the base of the PR and between 5f02f79 and f53c779.

📒 Files selected for processing (6)
  • packages/javascript/src/index.ts
  • packages/react/src/components/adapters/Consent.tsx
  • packages/react/src/components/adapters/ConsentCheckboxList.tsx
  • packages/react/src/components/presentation/auth/AuthOptionFactory.tsx
  • packages/react/src/components/primitives/Tooltip/Tooltip.tsx
  • packages/vue/src/components/auth/sign-in/AuthOptionFactoryCore.ts
💤 Files with no reviewable changes (1)
  • packages/react/src/components/adapters/ConsentCheckboxList.tsx

Comment thread packages/react/src/components/primitives/Tooltip/Tooltip.tsx
Comment thread packages/vue/src/components/auth/sign-in/AuthOptionFactoryCore.ts
zesu22 added 2 commits July 27, 2026 14:33
Signed-off-by: Zeeshan Mehboob <zeeshan.mehboob@infosys.com>
Signed-off-by: Zeeshan Mehboob <zeeshan.mehboob@infosys.com>

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/react/src/components/adapters/Consent.tsx (2)

95-98: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Keep consent configuration typed and runtime-safe.

config accepts arbitrary unknown values but is then treated as ConsentConfig; a truthy non-string label can reach template resolution and crash when .replace() is called. Type this prop as Partial<ConsentConfig> and/or normalize each field before resolving.

Proposed fix
-  config?: Record<string, unknown>;
+  config?: Partial<ConsentConfig>;

Also applies to: 138-142

🤖 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/adapters/Consent.tsx` around lines 95 - 98,
Update the Consent component’s config prop and its related usage to use
Partial<ConsentConfig> instead of Record<string, unknown>. Before template
resolution, normalize or validate configurable fields—especially label values—so
only strings reach .replace(), while preserving existing ConsentConfig defaults
and behavior.

162-167: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Represent partially selected optional attributes.

checkOptValue returns false when any optional item is skipped, so both zero and partial selections render the master toggle as unchecked. Track some/all derived from the optional form values, and add the indeterminate state to Toggle if an indeterminate role="switch"/checkbox state is required.

🤖 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/adapters/Consent.tsx` around lines 162 - 167,
Update checkOptValue and the associated Toggle state to distinguish zero,
partial, and complete optional selections: derive whether some and all optional
values are true rather than returning only every(...). Preserve the unchecked
state for zero selections, mark the toggle checked only when all are selected,
and pass the derived indeterminate state to Toggle when the switch/checkbox API
supports it.
🧹 Nitpick comments (1)
packages/react/src/components/presentation/auth/AuthOptionFactory.tsx (1)

397-397: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Add regression coverage for strict consent decisions.

Cover 'true', 'false', missing, empty, and deny-action values so future form-value changes cannot accidentally approve optional attributes.

🤖 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` at
line 397, Add regression tests around the consent decision logic producing the
approved value, covering optional attributes with form values of 'true',
'false', missing, empty, and deny-action cases. Verify only the exact 'true'
value approves when the action is not deny, while all other values and deny
actions remain unapproved.
🤖 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.

Outside diff comments:
In `@packages/react/src/components/adapters/Consent.tsx`:
- Around line 95-98: Update the Consent component’s config prop and its related
usage to use Partial<ConsentConfig> instead of Record<string, unknown>. Before
template resolution, normalize or validate configurable fields—especially label
values—so only strings reach .replace(), while preserving existing ConsentConfig
defaults and behavior.
- Around line 162-167: Update checkOptValue and the associated Toggle state to
distinguish zero, partial, and complete optional selections: derive whether some
and all optional values are true rather than returning only every(...). Preserve
the unchecked state for zero selections, mark the toggle checked only when all
are selected, and pass the derived indeterminate state to Toggle when the
switch/checkbox API supports it.

---

Nitpick comments:
In `@packages/react/src/components/presentation/auth/AuthOptionFactory.tsx`:
- Line 397: Add regression tests around the consent decision logic producing the
approved value, covering optional attributes with form values of 'true',
'false', missing, empty, and deny-action cases. Verify only the exact 'true'
value approves when the action is not deny, while all other values and deny
actions remain unapproved.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: caa51360-d1ba-4823-b64f-8d1942819c23

📥 Commits

Reviewing files that changed from the base of the PR and between f53c779 and 49eb29d.

📒 Files selected for processing (3)
  • packages/react/src/components/adapters/Consent.tsx
  • packages/react/src/components/presentation/auth/AuthOptionFactory.tsx
  • packages/react/src/components/primitives/Tooltip/Tooltip.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/react/src/components/primitives/Tooltip/Tooltip.tsx

Signed-off-by: Zeeshan Mehboob <zeeshan.mehboob@infosys.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.

eSignet-Thunder:UI enhancements to JavaScript SDK — Tooltip, attribute info icons, and master toggle for optional attributes

2 participants