Skip to content

fix: InputField story broken (@d1rshan)#7945

Open
d1rshan wants to merge 2 commits into
monkeytypegame:masterfrom
d1rshan:fix/storybook-input-field
Open

fix: InputField story broken (@d1rshan)#7945
d1rshan wants to merge 2 commits into
monkeytypegame:masterfrom
d1rshan:fix/storybook-input-field

Conversation

@d1rshan
Copy link
Copy Markdown
Contributor

@d1rshan d1rshan commented May 13, 2026

Regression

Commit 0c07e10 (PR #7918) removed the showIndicator prop from InputField and switched to props.field().options.validators as the "Gate" to show/hide FieldIndicator, but didn't update InputField.stories.tsx. The story's field mock was missing options, causing props.field().options throw error

Fix

Added options: { validators } support to createFieldMock, updated withIndicator to pass a dummy validator, and removed the dead showIndicator prop.

Copilot AI review requested due to automatic review settings May 13, 2026 05:51
@monkeytypegeorge monkeytypegeorge added the frontend User interface or web stuff label May 13, 2026
@github-actions github-actions Bot added the waiting for review Pull requests that require a review before continuing label May 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a Storybook regression for InputField after showIndicator prop removal by aligning the story’s mock field shape with the component’s current field().options.validators gate.

Changes:

  • Extend createFieldMock to include options.validators
  • Update withIndicator story to provide a dummy validator so the indicator renders
  • Remove showIndicator from Storybook component typing + controls
Comments suppressed due to low confidence (1)

frontend/storybook/stories/InputField.stories.tsx:46

  • createFieldMock omits handleBlur/handleChange, but InputField calls props.field().handleBlur() / handleChange() on events; interacting with this story (typing/blur) will throw at runtime. Add no-op implementations (or a small signal-backed value) to the mock so the story is safe to interact with.
  return {
    name: options.name ?? "test",
    options: {
      validators: options.validators,
    },
    get state() {
      return {
        value: options.value ?? "",
        meta: stateMeta,
      };
    },
    getMeta() {
      return {
        hasWarning: options.meta?.hasWarning ?? false,
        warnings: options.meta?.warnings ?? [],
      };
    },
  } as unknown as AnyFieldApi;

Comment on lines 16 to 21
function createFieldMock(options: {
name?: string;
value?: string;
meta?: MetaState;
validators?: object;
}) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend User interface or web stuff waiting for review Pull requests that require a review before continuing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants