Skip to content

Commit

Permalink
Fix TextInput, TextArea, and Select width bug (#828)
Browse files Browse the repository at this point in the history
* fix bug where TextInput width would expand to length of validation message

* remove duplicated styles

* fixed same bug in TextArea

* remove redundant style

* fix width bug

* remove unnecessary width

* add changeset
  • Loading branch information
joshfarrant authored Dec 5, 2024
1 parent 8c3448d commit 652e7ff
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/sour-numbers-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react-brand': patch
---

Fixed bug where `TextInput`, `TextArea`, and `Select` components would expand to the width of a the validation message on the parent `FormControl`.
10 changes: 1 addition & 9 deletions packages/react/src/forms/Select/Select.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@
padding-block: 0;
}

/*
* Visual states
*/

.Select--fullWidth {
width: 100%;
}

/*
* Select wrapper
*/
Expand Down Expand Up @@ -128,7 +120,7 @@
}

.Select-wrapper--fullWidth {
display: flex;
width: 100%;
}

/*
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/forms/Select/Select.module.css.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ declare const styles: {
readonly "Select--medium": string;
readonly "Select-wrapper--large": string;
readonly "Select--large": string;
readonly "Select--fullWidth": string;
readonly "Select-wrapper--fullWidth": string;
readonly "Select--success": string;
readonly "Select--error": string;
Expand Down
5 changes: 5 additions & 0 deletions packages/react/src/forms/TextInput/TextInput.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,14 @@
}

.TextInput-wrapper--fullWidth {
width: 100%;
display: flex;
}

.TextInput-wrapper:not(.TextInput-wrapper--fullWidth) {
width: min-content;
}

.TextInput-wrapper--monospace {
font-family: var(--brand-fontStack-monospace);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/react/src/forms/Textarea/Textarea.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
outline: none;
}

.Textarea:focus {
outline: none;
}

.Textarea-resize--vertical {
resize: vertical;
}
Expand Down Expand Up @@ -98,6 +94,10 @@
display: flex;
}

.Textarea-wrapper:not(.Textarea-wrapper--fullWidth) {
width: min-content;
}

.Textarea-wrapper--monospace {
font-family: var(--brand-fontStack-monospace);
}
Expand Down

0 comments on commit 652e7ff

Please sign in to comment.