-
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 a759d8f
Showing
9 changed files
with
244 additions
and
31 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react' | ||
|
||
type WithChildrenProps = { | ||
children?: React.ReactNode | ||
} | ||
|
||
function withChildren<T>( | ||
Component: React.ComponentType<T> | ||
): React.ComponentType<T & WithChildrenProps> { | ||
Component['_supportsSpacingProps'] = 'children' | ||
return Component | ||
} | ||
|
||
export default withChildren |
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> | ||
) | ||
} |