From 3a8925b7682de67cb790cb6739cfb15ffb866b18 Mon Sep 17 00:00:00 2001 From: Scott Rees <6165315+reesscot@users.noreply.github.com> Date: Wed, 16 Mar 2022 19:20:49 -0700 Subject: [PATCH] fix: update complex field components to allow absolute positioning (#1530) --- .changeset/thick-pumas-guess.md | 7 +++++++ packages/react/src/primitives/Radio/Radio.tsx | 15 +++++++++++++++ .../src/primitives/SliderField/SliderField.tsx | 4 +++- .../primitives/StepperField/StepperField.tsx | 18 ++++++++++++++++++ .../primitives/TextAreaField/TextAreaField.tsx | 18 ++++++++++++++++-- .../src/primitives/TextField/TextField.tsx | 16 +++++++++++++++- 6 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 .changeset/thick-pumas-guess.md diff --git a/.changeset/thick-pumas-guess.md b/.changeset/thick-pumas-guess.md new file mode 100644 index 00000000000..447eba2d015 --- /dev/null +++ b/.changeset/thick-pumas-guess.md @@ -0,0 +1,7 @@ +--- +"@aws-amplify/ui-react": patch +--- + +fix: update complex field components (TextField, TextAreaField, etc) to apply absolute positioning from Figma + +Figma to Studio integration will absolutely position components when autolayout is not enabled in Figma. This causes an issue for field components that were passing position, top, and left, and padding down to the input element, causing the layout not to match Figma. This is fixed by moving the absolute position props and padding up to the container Flex element. diff --git a/packages/react/src/primitives/Radio/Radio.tsx b/packages/react/src/primitives/Radio/Radio.tsx index 09dbf4f7abd..507fb0406a3 100644 --- a/packages/react/src/primitives/Radio/Radio.tsx +++ b/packages/react/src/primitives/Radio/Radio.tsx @@ -17,6 +17,14 @@ export const RadioPrimitive: Primitive = ( testId, value, labelPosition: radioLabelPosition, + height, // @TODO: remove custom destructuring for 3.0 release + width, // @TODO: remove custom destructuring for 3.0 release + bottom, // @TODO: remove custom destructuring for 3.0 release + left, // @TODO: remove custom destructuring for 3.0 release + position, // @TODO: remove custom destructuring for 3.0 release + padding, // @TODO: remove custom destructuring for 3.0 release + right, // @TODO: remove custom destructuring for 3.0 release + top, // @TODO: remove custom destructuring for 3.0 release ...rest }, ref @@ -54,6 +62,13 @@ export const RadioPrimitive: Primitive = ( className={classNames(ComponentClassNames.Radio, className)} data-disabled={shouldBeDisabled} data-label-position={labelPosition} + width={width} + bottom={bottom} + top={top} + right={right} + left={left} + position={position} + padding={padding} > {children && ( = ( const descriptionId = useStableId(); const ariaDescribedBy = descriptiveText ? descriptionId : undefined; - const { flexContainerStyleProps, rest } = splitPrimitiveProps(_rest); + const { flexContainerStyleProps, baseStyleProps, rest } = + splitPrimitiveProps(_rest); const isControlled = value !== undefined; @@ -86,6 +87,7 @@ const SliderFieldPrimitive: Primitive = ( )} testId={testId} data-size={size} + {...baseStyleProps} {...flexContainerStyleProps} >