-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(FieldBlock): label can be clicked after focusing input (#3190)
Fixes #2979 The label was an internal component and was re-initialized on each re-render of FieldBlock. Fixed by removing the internal component and instead just generating the props. --------- Co-authored-by: Tobias Høegh <[email protected]>
- Loading branch information
1 parent
16ed821
commit 95b37e7
Showing
3 changed files
with
69 additions
and
16 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
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
28 changes: 28 additions & 0 deletions
28
packages/dnb-eufemia/src/extensions/forms/FieldBlock/stories/FieldBlock.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,28 @@ | ||
import React, { useCallback } from 'react' | ||
import FieldBlock from '../FieldBlock' | ||
import Input from '../../../../components/Input' | ||
import { useDataValue } from '../../hooks' | ||
|
||
export default { | ||
title: 'Eufemia/Extensions/Forms/FieldBlock', | ||
} | ||
|
||
export function FieldBlockLabel() { | ||
const fromInput = useCallback(({ value }) => value, []) | ||
const { value, handleChange, handleFocus, handleBlur } = useDataValue({ | ||
value: 'foo', | ||
fromInput, | ||
}) | ||
|
||
return ( | ||
<FieldBlock label="Label" forId="unique"> | ||
<Input | ||
id="unique" | ||
value={value} | ||
on_change={handleChange} | ||
on_focus={handleFocus} | ||
on_blur={handleBlur} | ||
/> | ||
</FieldBlock> | ||
) | ||
} |