An open source design system that's fully customizable and agent ready
TypeScript
fix(ChatComposerInput): account for padding in the single-line minHeight floor (#6654)
Ojas Mutreja33ddd449c45e
diff --git a/.changeset/chat-composer-input-disabled-height.md b/.changeset/chat-composer-input-disabled-height.mdnew file mode 100644index 0000000000..3e30d13b56--- /dev/null+++ b/.changeset/chat-composer-input-disabled-height.md@@ -0,0 +1,9 @@+---+'@astryxdesign/core': patch+---++[fix] `ChatComposerInput`: an empty input no longer shrinks by 8px when `isDisabled` flips to `true`, which shifted anything bottom-aligned beside it (e.g. a send button in a grid row).++The root's `minHeight` was set to the shared line-height only, not the padding `editable` and `placeholder` both add on top of it — normally immaterial, since the editable region reserves its own padded box even when empty. A disabled, empty `contentEditable` region stops reserving that empty line at all in Chromium, and the absolutely positioned placeholder standing in for it doesn't contribute to layout height, so the root fell back to just the line-height and lost the padding. `minHeight` now explicitly accounts for both.++@HelloOjasMutrejadiff --git a/apps/storybook/stories/ChatComposerInput.stories.tsx b/apps/storybook/stories/ChatComposerInput.stories.tsxindex 2de122409e..268b770272 100644--- a/apps/storybook/stories/ChatComposerInput.stories.tsx+++ b/apps/storybook/stories/ChatComposerInput.stories.tsx@@ -152,6 +152,50 @@ export const Disabled: Story = {),};+/**+ * Toggling `isDisabled` on an empty input must not change its own height —+ * an empty disabled editable region stops reserving its line in Chromium,+ * and the absolutely positioned placeholder standing in for it doesn't+ * contribute to layout height, so without an explicit floor the root+ * shrinks by its own padding and shifts anything bottom-aligned beside it+ * (#6651).+ */+function DisabledHeightToggleExample() {+ const [isDisabled, setIsDisabled] = useState(false);+ return (+ <div>+ <button type="button" onClick={() => setIsDisabled(value => !value)}>+ Toggle disabled: {String(isDisabled)}+ </button>+ <div+ style={{+ display: 'grid',+ gridTemplateColumns: 'minmax(0, 1fr) auto',+ alignItems: 'end',+ gap: 12,+ padding: 12,+ border: '1px solid gray',+ width: 360,+ }}>+ <ChatComposerInput+ value=""+ onChange={() => {}}+ placeholder="Type a message…"+ label="Reproduction input"+ isDisabled={isDisabled}+ />+ <button type="button" style={{width: 36, height: 36}}>+ ↑+ </button>+ </div>+ </div>+ );+}++export const DisabledHeightToggle: Story = {+ render: () => <DisabledHeightToggleExample />,+};+/** Max rows — scrolls after 3 lines */export const MaxRows: Story = {render: () => (diff --git a/packages/core/src/Chat/ChatComposerInput.tsx b/packages/core/src/Chat/ChatComposerInput.tsxindex e63c86f910..3d7c72637c 100644--- a/packages/core/src/Chat/ChatComposerInput.tsx+++ b/packages/core/src/Chat/ChatComposerInput.tsx@@ -238,7 +238,18 @@ const styles = stylex.create({position: 'relative',display: 'flex',flexDirection: 'column',- minHeight: `${LINE_HEIGHT_PX}px`,+ // The single-line floor, not just the line-height: `editable` and+ // `placeholder` both add `spacingVars['--spacing-1']` padding on the+ // block axis on top of their shared line-height, and normally that's+ // what keeps the root this tall (the editable region reserves its own+ // padded box even when empty). A disabled, empty editable stops+ // reserving that empty line at all in Chromium (contentEditable=false+ // collapses to just its padding), and the absolutely positioned+ // placeholder that would otherwise stand in for it doesn't contribute+ // to layout height — so without this explicit floor accounting for the+ // same padding, the root shrinks by that padding's height the moment+ // isDisabled flips true, moving anything bottom-aligned beside it.+ minHeight: `calc(${LINE_HEIGHT_PX}px + 2 * ${spacingVars['--spacing-1']})`,},editable: {outline: 'none',