Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: textarea focus with proper padding #399

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

スクリーンショット 2023-10-10 11 00 17
maybe replace padding with border in the future?

/* 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
Loading