Skip to content

Commit

Permalink
fix: textarea click focus with proper padding
Browse files Browse the repository at this point in the history
  • Loading branch information
yue4u committed Oct 9, 2023
1 parent 4ff3435 commit 4c3a4de
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/react/src/components/TextArea/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
<StyledTextarea
ref={mergeRefs(textareaRef, forwardRef, ariaRef)}
rows={rows}
noBottomPadding={showCount}
withCountPadding={showCount}
{...inputProps}
/>
{showCount && (
Expand Down Expand Up @@ -170,7 +170,6 @@ const TextFieldLabel = styled(FieldLabel)`
const StyledTextareaContainer = styled.div<{ rows: number; invalid: boolean }>`
position: relative;
overflow: hidden;
padding: 0 8px;
${(p) =>
theme((o) => [
Expand All @@ -191,7 +190,7 @@ const StyledTextareaContainer = styled.div<{ rows: number; invalid: boolean }>`
`};
`

const StyledTextarea = styled.textarea<{ noBottomPadding: boolean }>`
const StyledTextarea = styled.textarea<{ withCountPadding: boolean }>`
border: none;
outline: none;
resize: none;
Expand All @@ -201,10 +200,15 @@ const StyledTextarea = styled.textarea<{ noBottomPadding: boolean }>`
/* Prevent zooming for iOS Safari */
transform-origin: top left;
transform: scale(0.875);
width: calc(100% / 0.875);
width: calc((100% - 16px) / 0.875);
font-size: calc(14px / 0.875);
line-height: calc(22px / 0.875);
padding: calc(9px / 0.875) 0 ${(p) => (p.noBottomPadding ? 0 : '')};
padding: calc(9px / 0.875) calc(8px / 0.875)
${(p) => (p.withCountPadding ? 0 : '')};
/* Using padding on textarea will cause text overflow */
/* v_________________ (one row (22px) + padding (9px)) / scale (0.875) */
border-bottom: ${(p) => (p.withCountPadding ? 'calc(31px / 0.875)' : '0')}
transparent solid;
${({ rows = 1 }) => css`
height: calc(22px / 0.875 * ${rows});
Expand Down

0 comments on commit 4c3a4de

Please sign in to comment.