fix: InputField story broken (@d1rshan)#7945
Open
d1rshan wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
createFieldMockto includeoptions.validators - Update
withIndicatorstory to provide a dummy validator so the indicator renders - Remove
showIndicatorfrom 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; | ||
| }) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Regression
Commit 0c07e10 (PR #7918) removed the
showIndicatorprop from InputField and switched toprops.field().options.validatorsas 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 errorFix
Added options: { validators } support to createFieldMock, updated withIndicator to pass a dummy validator, and removed the dead showIndicator prop.