Skip to content

fix: Input variant refactor#7579

Merged
raunakab merged 6 commits intomainfrom
input-variant-refactor
Jan 20, 2026
Merged

fix: Input variant refactor#7579
raunakab merged 6 commits intomainfrom
input-variant-refactor

Conversation

@raunakab
Copy link
Copy Markdown
Contributor

@raunakab raunakab commented Jan 20, 2026

Description

Address final remaining comment which was accidentally ignored prior to merge in the previous PR (#7575).

Additional Options

  • [Optional] Override Linear Check

raunakab and others added 6 commits January 20, 2026 10:03
- Replace boolean props (internal, error, disabled) with single variant prop
- Add new 'readOnly' variant for non-editable inputs with minimal styling
- Variant options: 'primary' | 'internal' | 'error' | 'disabled' | 'readOnly'
- Update all input consumers to use new variant API
- Add textClasses support for consistent text color styling

Components updated:
- InputTypeIn, InputTextArea, InputSelect, InputFile
- InputKeyValue, InputComboBox, ListFieldInput
- PasswordInputTypeIn, InputAvatar
- Form field wrappers (InputTypeInField, etc.)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Destructure readOnly from props to prevent it from being spread and
overriding the explicit readOnly attribute. This ensures variant="readOnly"
correctly enforces read-only behavior even if readOnly={false} is passed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Form field components now check if the variant is "disabled" or "readOnly"
before applying error styling, ensuring non-editable fields maintain their
intended appearance regardless of validation state.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The component now derives `isDisabled` from both the `disabled` boolean
prop and `variant === "disabled"`, ensuring consistent behavior when
either approach is used. This affects the file picker function, icon
button, and hidden file input.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The component now treats both disabled and readOnly variants as
non-editable states. File picking, paste handling, and the icon button
are all blocked when variant is "readOnly", making the component
behavior consistent with its visual appearance.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@raunakab raunakab requested a review from a team as a code owner January 20, 2026 19:10
@raunakab raunakab enabled auto-merge January 20, 2026 19:11
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Jan 20, 2026

Greptile Summary

Completed the readOnly variant handling in InputFile component by adding paste protection and properly propagating the readOnly state to the underlying InputTypeIn component.

  • Added isReadOnly check derived from variant === "readOnly"
  • Introduced isNonEditable variable combining isDisabled || isReadOnly for consistent behavior
  • Protected handlePaste() function from allowing paste when component is non-editable
  • Updated readOnly prop passed to InputTypeIn to include isReadOnly state: readOnly={isFileMode || isReadOnly}
  • Updated comment to reflect handling of both disabled and readOnly states

This change ensures that when variant="readOnly", the component is truly non-editable: file picking, paste operations, and direct input are all blocked, matching the visual appearance and user expectations.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Clean, focused refactor that completes the readOnly variant handling. The changes are logically sound, maintain consistency with existing patterns, and properly guard all interaction points (file picking, paste, and input). No breaking changes or edge cases identified.
  • No files require special attention

Important Files Changed

Filename Overview
web/src/refresh-components/inputs/InputFile.tsx Enhanced readOnly variant handling by adding paste protection and proper readOnly propagation to InputTypeIn component

Sequence Diagram

sequenceDiagram
    participant User
    participant InputFile
    participant InputTypeIn
    participant FileReader

    Note over InputFile: variant="readOnly" or "disabled"
    InputFile->>InputFile: isReadOnly = variant === "readOnly"
    InputFile->>InputFile: isDisabled = disabled || variant === "disabled"
    InputFile->>InputFile: isNonEditable = isDisabled || isReadOnly

    User->>InputFile: Click file picker button
    InputFile->>InputFile: openFilePicker() checks isNonEditable
    alt isNonEditable
        InputFile-->>User: Action blocked
    else editable
        InputFile->>FileReader: Open file picker
        FileReader-->>InputFile: File selected
        InputFile->>InputFile: setValue(content)
    end

    User->>InputTypeIn: Paste text
    InputTypeIn->>InputFile: handlePaste()
    InputFile->>InputFile: Check isNonEditable
    alt isNonEditable
        InputFile-->>User: Paste blocked
    else editable
        InputFile->>InputFile: setValue(pastedText)
        InputFile->>InputFile: setIsFileMode(false)
    end

    Note over InputFile,InputTypeIn: readOnly prop = isFileMode || isReadOnly
    InputFile->>InputTypeIn: Pass readOnly prop
    InputTypeIn->>InputTypeIn: Render with readOnly state
Loading

@raunakab raunakab changed the title Input variant refactor fix: Input variant refactor Jan 20, 2026
@raunakab raunakab disabled auto-merge January 20, 2026 21:04
@raunakab raunakab merged commit 1c7bb6e into main Jan 20, 2026
87 of 96 checks passed
@raunakab raunakab deleted the input-variant-refactor branch January 20, 2026 21:04
rohoswagger pushed a commit that referenced this pull request Jan 20, 2026
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
jessicasingh7 pushed a commit that referenced this pull request Jan 21, 2026
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.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.

1 participant