-
Notifications
You must be signed in to change notification settings - Fork 0
[LC-118] chore: adding a remix text area story & fix: #7 Custom attribute getting added to inputs unnecessarily #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9f91553
chore: adding a remix text area story
jaruesink 9765d6e
fix: simplify text area to remove need to forward ref to base text area
jaruesink 7c60047
fix: applying code rabbit suggestion on memoizing custom components t…
jaruesink 6c3ec06
fix: removing non dom attributes from getting to the inputs
jaruesink 1e16d7b
fix: tests
jaruesink 4fc4dd3
chore: removing useMemo per code rabbit
jaruesink 767272e
Merge branch 'main' of github.com:lambda-curry/forms into text-area-s…
Bfunk54 4bac919
used a timeout to make sure everything renders before checking for it
Bfunk54 610d009
fixed small bug where two error messages would be rendered
Bfunk54 19b0854
added a changeset
Bfunk54 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@lambdacurry/forms": minor | ||
| "@lambdacurry/forms-docs": minor | ||
| --- | ||
|
|
||
| Added remix textarea story and fixes a react error |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,14 @@ | ||
| { | ||
| "cSpell.words": ["autodocs", "biomejs", "Filenaming", "hookform", "isbot", "lucide", "shadcn", "sonner"] | ||
| "cSpell.words": ["autodocs", "biomejs", "Filenaming", "hookform", "isbot", "lucide", "shadcn", "sonner"], | ||
| "editor.defaultFormatter": "biomejs.biome", | ||
| "[typescript]": { | ||
| "editor.defaultFormatter": "biomejs.biome" | ||
| }, | ||
| "[typescriptreact]": { | ||
| "editor.defaultFormatter": "biomejs.biome" | ||
| }, | ||
| "editor.codeActionsOnSave": { | ||
| "source.fixAll.biome": "explicit", | ||
| "source.organizeImports.biome": "explicit" | ||
| } | ||
| } |
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
This file was deleted.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,18 @@ | ||
| import { useRemixFormContext } from 'remix-hook-form' | ||
| import { Checkbox, type CheckboxProps } from '../ui/checkbox' | ||
| import { useRemixFormContext } from 'remix-hook-form'; | ||
| import { Checkbox, type CheckboxProps } from '../ui/checkbox'; | ||
| import { RemixFormControl, RemixFormDescription, RemixFormLabel, RemixFormMessage } from './remix-form'; | ||
| import type { FieldComponents } from '../ui/form'; | ||
|
|
||
| export type RemixCheckboxProps = Omit<CheckboxProps, 'control'>; | ||
|
|
||
| export function RemixCheckbox(props: RemixCheckboxProps) { | ||
| const { control } = useRemixFormContext(); | ||
|
|
||
|
|
||
| const components: Partial<FieldComponents> = { | ||
| const components = { | ||
| FormDescription: RemixFormDescription, | ||
| FormControl: RemixFormControl, | ||
| FormLabel: RemixFormLabel, | ||
| FormMessage: RemixFormMessage, | ||
| }; | ||
|
|
||
| return <Checkbox control={control} {...props} components={components} />; | ||
| } | ||
| } |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,18 @@ | ||
| import { useRemixFormContext } from 'remix-hook-form'; | ||
| import { Textarea, type TextareaProps } from '../ui/textarea'; | ||
| import { FormField, FormItem } from '../ui/form'; | ||
| export interface RemixTextareaProps extends Omit<TextareaProps, 'control'> { | ||
| label?: string; | ||
| description?: string; | ||
| } | ||
| import { RemixFormControl, RemixFormDescription, RemixFormLabel, RemixFormMessage } from './remix-form'; | ||
|
|
||
| export type RemixTextareaProps = Omit<TextareaProps, 'control'>; | ||
|
|
||
| export function RemixTextarea(props: RemixTextareaProps) { | ||
| const { control } = useRemixFormContext(); | ||
|
|
||
| return ( | ||
| <FormField | ||
| control={control} | ||
| name={props.name ?? ''} | ||
| render={({ field }) => ( | ||
| <FormItem> | ||
| <Textarea {...field} {...props} /> | ||
| </FormItem> | ||
| )} | ||
| /> | ||
| ); | ||
| const components = { | ||
| FormControl: RemixFormControl, | ||
| FormLabel: RemixFormLabel, | ||
| FormDescription: RemixFormDescription, | ||
| FormMessage: RemixFormMessage, | ||
| }; | ||
|
|
||
| return <Textarea control={control} components={components} {...props} />; | ||
| } | ||
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Memoize the
componentsobject to prevent unnecessary re-rendersCurrently, the
componentsobject is recreated on every render, which can lead to unnecessary re-renders if theTextareacomponent relies on referential equality for optimizations. Consider wrapping it in auseMemohook to ensure the object reference remains stable across renders.Apply this diff to memoize the
componentsobject:Also, add the import statement at the top of the file:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You said this wouldn't add much performance enhancement, so I'm leaving as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaruesink, understood. I'll keep this in mind for future reviews.
✏️ Learnings added