Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/field-content-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@codecora/ui': patch
---

`Field` packs its rows at the top (`content-start`), so a field stretched by its parent (a form row beside a taller field, a stretching flex column) keeps its `Input`, `Select` or `Textarea` at the control height instead of growing it (#190).
3 changes: 2 additions & 1 deletion packages/ui/src/lib/Field.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
);
</script>

<div data-slot="field" class="grid gap-1">
<!-- content-start: a stretched field (a form row beside a taller field) keeps its control at h-control. -->
<div data-slot="field" class="grid content-start gap-1">
<label for={id} class="text-sm leading-[inherit] font-medium">
{label}{#if required}<span class="text-destructive" aria-hidden="true"> *</span>{/if}
</label>
Expand Down
5 changes: 5 additions & 0 deletions packages/ui/src/lib/primitives.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ describe('Field with Input', () => {
expect(input).toBeInvalid();
expect(input).toHaveAccessibleDescription(/Error:\s*Enter a valid email/);
});

it('packs its rows at the top, so a stretched field does not grow the control', () => {
const { container } = render(Field, { label: 'Email', children: control });
expect(container.querySelector('[data-slot=field]')).toHaveClass('grid', 'content-start');
});
});

describe('Field with a real Input', () => {
Expand Down
Loading