-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: text input and date input to be fixed (#3944)
* fix: date input not working properly * fix: text input and date input to be fixed * fix: add on change value * ci: fix unit testing * fix: unit testing
- Loading branch information
1 parent
4483ab9
commit d571c5e
Showing
16 changed files
with
150 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
--- | ||
"@ultraviolet/form": patch | ||
--- | ||
|
||
- Minor fixes to `<TextInputV2 />` component | ||
- Fixed issue with `<DateInput />` component preventing the input to be edited |
This file contains 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,16 @@ | ||
--- | ||
"@ultraviolet/ui": patch | ||
--- | ||
|
||
Fix `<TextInputV2 />` prop `onChange` will now take function with event. | ||
|
||
```tsx | ||
// Before | ||
onChange={value => value} | ||
|
||
// After | ||
onChangeValue={value => value} | ||
onChange={event => event.target.value} | ||
``` | ||
|
||
This will also fix `<DateInput />` issues such as editing the input value. |
This file contains 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 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 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 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 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 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
38 changes: 38 additions & 0 deletions
38
packages/ui/src/components/TextInputV2/__stories__/ControlledVSUncontrolled.stories.tsx
This file contains 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,38 @@ | ||
import type { StoryFn } from '@storybook/react' | ||
import { useState } from 'react' | ||
import { TextInputV2 } from '..' | ||
import { Stack } from '../../Stack' | ||
import { Text } from '../../Text' | ||
|
||
export const ControlledVSUncontrolled: StoryFn<typeof TextInputV2> = props => { | ||
const [value, setValue] = useState('content') | ||
|
||
return ( | ||
<Stack direction="column" gap={2}> | ||
<TextInputV2 label="Uncontrolled" defaultValue="content" {...props} /> | ||
<Stack gap={1}> | ||
<TextInputV2 | ||
label="Controlled" | ||
value={value} | ||
onChange={event => setValue(event.target.value)} | ||
{...props} | ||
/> | ||
<Text as="p" variant="body" sentiment="neutral"> | ||
We can get the value from the input, which is:{' '} | ||
<Text as="span" variant="body" sentiment="neutral" italic> | ||
{value} | ||
</Text> | ||
</Text> | ||
</Stack> | ||
</Stack> | ||
) | ||
} | ||
|
||
ControlledVSUncontrolled.parameters = { | ||
docs: { | ||
description: { | ||
story: | ||
'The component can be controlled or uncontrolled.\n\n The difference is that in the controlled version, the `value` and `onChange` is passed as a prop and the component does not manage its own state.\n\n In the uncontrolled version, the component manages its own state. For more information check [React documentation](https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components).', | ||
}, | ||
}, | ||
} |
This file contains 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 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 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 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 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 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.