Skip to content

Conversation

@ryan953
Copy link
Member

@ryan953 ryan953 commented Jan 17, 2026

Summary

Refactors BooleanField from a class component to a functional component to align with modern React patterns and Sentry's frontend guidelines (no new class components).

This component was identified as a stateless class component (no internal state management), making it an ideal candidate for conversion to a functional component.

Changes

  • Converted class component to functional component
  • Removed Component import and class syntax
  • Made event parameter optional in handleChange to match OnEvent type signature
  • Simplified event type handling (React.ChangeEvent | React.FormEvent)
  • Removed redundant coerceValue helper method (inlined logic)
  • Maintained all existing functionality and behavior

Test plan

  • ✅ Linting passes
  • ✅ Accessibility tests pass (static/app/components/forms/fields/accessibility.spec.tsx)
  • ✅ No functional changes - component behavior is identical

Refactors BooleanField from a class component to a functional component to align with modern React patterns and Sentry's frontend guidelines (no new class components).

Changes:
- Converted class component to functional component
- Removed Component import and class syntax
- Made event parameter optional in handleChange to match OnEvent type
- Simplified event type handling
- Removed redundant coerceValue helper (inlined logic)
- Maintained all existing functionality and behavior
@ryan953 ryan953 requested a review from a team as a code owner January 17, 2026 04:09
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jan 17, 2026
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

<Confirm
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
renderMessage={() => confirm[(!value).toString()]}
onConfirm={() => handleChange()}
Copy link
Contributor

Choose a reason for hiding this comment

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

Confirm dialog sets undefined instead of toggled value

High Severity

When the confirm dialog's onConfirm callback triggers handleChange() without an event argument, FormField.getValueFromEvent() receives (newValue, undefined). Since the second argument is undefined, defined(e) returns false, causing value to be extracted as event?.target?.value which evaluates to undefined (because a boolean has no target property). The old code passed handleChange({}), where the empty object made defined({}) return true, correctly using the first argument as the value.

Additional Locations (1)

Fix in Cursor Fix in Web

@ryan953 ryan953 marked this pull request as draft January 17, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants