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(combobox): placeholder cropping in Multiselect Combobox #3540

Merged
merged 3 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions .changeset/sour-knives-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@twilio-paste/combobox": patch
"@twilio-paste/core": patch
---

[Combobox] Fix `placeholder` cropping issue in MultiselectCombobox
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ interface GrowingInputProps {
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
id: string;
value?: HTMLInputElement["value"];
placeholder?: string;
}

export const GrowingInput = React.forwardRef<HTMLInputElement, GrowingInputProps>(
({ element = "GROWING_INPUT", onChange, initialValue = "", value, ...props }, ref) => {
({ element = "GROWING_INPUT", onChange, initialValue = "", value, placeholder = "", ...props }, ref) => {
const [text, setText] = React.useState(value || initialValue);

React.useEffect(() => {
Expand Down Expand Up @@ -42,7 +43,7 @@ export const GrowingInput = React.forwardRef<HTMLInputElement, GrowingInputProps
height="28px"
alignContent="center"
_after={{
content: `"${text}"`,
content: `"${text || placeholder || ""}"`,
fontFamily: "inherit",
fontSize: "fontSize30",
fontWeight: "fontWeightMedium",
Expand All @@ -58,6 +59,7 @@ export const GrowingInput = React.forwardRef<HTMLInputElement, GrowingInputProps
element={element}
type="text"
value={value != null ? value.replace(/ +/g, " ") : text}
placeholder={placeholder}
padding="space0"
onChange={(event) => {
event.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const MultiselectCombobox = React.forwardRef<HTMLInputElement, Multiselec
initialSelectedItems = [],
disabledItems,
inputValue,
placeholder,
insertAfter,
insertBefore,
items,
Expand Down Expand Up @@ -355,6 +356,7 @@ export const MultiselectCombobox = React.forwardRef<HTMLInputElement, Multiselec
disabled,
onKeyDown: handleKeyDown,
})}
placeholder={selectedItems.length === 0 ? placeholder : ""}
aria-describedby={helpTextId}
element={`${element}_ELEMENT`}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const GrowingInputDemo: StoryFn = () => {
<Label htmlFor={id}>Type in here:</Label>
<Box display="flex" alignItems="center">
<span> -&gt; </span>
<GrowingInput id={id} />
<GrowingInput id={id} placeholder="Long placeholder text with extra long spaces ." />
<span> &lt;- </span>
</Box>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const BottomOfScreen = (): React.ReactNode => {
labelText="Choose a Paste Component"
selectedItemsLabelText="Selected Paste components"
helpText="Paste components are the building blocks of your product UI."
placeholder="Search by SID or name"
items={filteredItems}
onInputValueChange={({ inputValue: newInputValue = "" }) => {
setInputValue(newInputValue);
Expand Down