-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(form): ensure any custom margin-bottom applied to inputs override…
… fieldSpacing Replaces the previous implementation which targeted `FormField` and `Fieldset` in the `Form` styles to apply the given `fieldSpacing` value. This prevented any custom values being set on an input when it was rendered as a child of `Form`. `FormSpacingProvider`, `FormContext` and a `addFormSpacing` util have been added to support applying the field spacing on a child that has not been passed a custom margin value. fix #5681
- Loading branch information
Showing
33 changed files
with
782 additions
and
196 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
9 changes: 9 additions & 0 deletions
9
src/__internal__/form-spacing-provider/form-spacing-context.ts
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,9 @@ | ||
import React from "react"; | ||
|
||
export interface FormSpacingContextProps { | ||
marginBottom?: string; | ||
} | ||
|
||
export const FormSpacingContext = React.createContext<FormSpacingContextProps>( | ||
{} | ||
); |
20 changes: 20 additions & 0 deletions
20
src/__internal__/form-spacing-provider/form-spacing-provider.component.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,20 @@ | ||
import React from "react"; | ||
import { | ||
FormSpacingContext, | ||
FormSpacingContextProps, | ||
} from "./form-spacing-context"; | ||
|
||
interface FormSpacingProviderProps extends FormSpacingContextProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
const FormSpacingProvider = ({ | ||
marginBottom, | ||
children, | ||
}: FormSpacingProviderProps) => ( | ||
<FormSpacingContext.Provider value={{ marginBottom }}> | ||
{children} | ||
</FormSpacingContext.Provider> | ||
); | ||
|
||
export default FormSpacingProvider; |
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,3 @@ | ||
export { FormSpacingContext } from "./form-spacing-context"; | ||
export type { FormSpacingContextProps } from "./form-spacing-context"; | ||
export { default } from "./form-spacing-provider.component"; |
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.