Skip to content

Confusing boolean expressions for selected and focus props in Options components #1824

@abhi-7-7

Description

@abhi-7-7

Problem
The following pattern appears in multiple places:

selected={selected || (multiple !== true && undefined)}
focus={cursor === i || undefined}

This is hard to read, causes TypeScript warnings, and introduces TODO/FIXME comments.

Expected Behavior
Clear, type-safe logic
No TODO/FIXME comments
No runtime change

Actual Behavior
Boolean logic mixes || and &&
TypeScript infers boolean | undefined
Requires inline comments to justify behavior

Proposed Fix
Replace with explicit ternary expressions:


selected={selected ? true : undefined}
focus={cursor === i ? true : undefined}

Why This Is Safe
Runtime behavior is identical
Improves readability
Removes TypeScript ambiguity

Scope
Options.tsx
OptionsPaginated.tsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions