fuselage icon indicating copy to clipboard operation
fuselage copied to clipboard

Confusing boolean expressions for selected and focus props in Options components

Open abhi-7-7 opened this issue 10 months ago • 2 comments

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

abhi-7-7 avatar Jan 09 '26 07:01 abhi-7-7

Hi @abhi-7-7, I’d like to work on this issue and submit a PR.

I’ll update Options.tsx and OptionsPaginated.tsx to replace the current boolean expressions with explicit ternary expressions as suggested, ensuring there’s no runtime behavior change while improving readability and TypeScript type safety.

Please let me know if that sounds good. Thanks!

devadharshini-162 avatar Jan 23 '26 18:01 devadharshini-162

@tassoevan I've successfully fixed the boolean logic issue in the Options components. Please assign this issue to me than i will test it and open a PR for my changed file. Thanks!

Image

MuhammadUmar7195 avatar Jan 25 '26 20:01 MuhammadUmar7195