Skip to content

Commit f12312d

Browse files
steipeteevan-YM
andauthored
fix(ui): align Skills filters (#100526)
Co-authored-by: 杨爱文 <[email protected]>
1 parent 286c020 commit f12312d

4 files changed

Lines changed: 43 additions & 2 deletions

File tree

ui/src/components/form-controls.browser.test.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ function readUiCss(): string {
3131
function controlsHtml() {
3232
return `
3333
<main>
34-
<label class="field"><input value="field input" /></label>
34+
<label class="field"><input type="text" value="field input" /></label>
3535
<label class="field"><textarea>field textarea</textarea></label>
3636
<label class="field"><select><option>field select</option></select></label>
37+
<label class="field checkbox"><input type="checkbox" /><span>field checkbox</span></label>
38+
<label class="field checkbox"><input type="radio" /><span>field radio</span></label>
3739
<input class="config-search__input" value="search" />
3840
<input class="settings-theme-import__input" value="theme" />
3941
<label class="config-raw-field"><textarea>raw config</textarea></label>
@@ -155,4 +157,33 @@ describeBrowserLayout("touch-primary form controls", () => {
155157
await closeMobileFixture(fixture);
156158
}
157159
});
160+
161+
it("aligns text controls without stretching checkbox and radio inputs", async () => {
162+
const fixture = await openMobileFixture();
163+
const { page } = fixture;
164+
try {
165+
const dimensions = await page.evaluate(() => {
166+
const height = (selector: string) => {
167+
const node = document.querySelector(selector);
168+
if (!(node instanceof HTMLElement)) {
169+
throw new Error(`Missing control ${selector}`);
170+
}
171+
return node.getBoundingClientRect().height;
172+
};
173+
return {
174+
checkbox: height('.field input[type="checkbox"]'),
175+
radio: height('.field input[type="radio"]'),
176+
select: height(".field select"),
177+
text: height('.field input[type="text"]'),
178+
};
179+
});
180+
181+
expect(dimensions.text).toBe(38);
182+
expect(dimensions.select).toBe(38);
183+
expect(dimensions.checkbox).toBeLessThan(38);
184+
expect(dimensions.radio).toBeLessThan(38);
185+
} finally {
186+
await closeMobileFixture(fixture);
187+
}
188+
});
158189
});

ui/src/pages/skills/view.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ describe("renderSkills", () => {
137137
await Promise.resolve();
138138

139139
const selector = container.querySelector<HTMLSelectElement>('select[name="skills-agent"]');
140+
const filter = container.querySelector<HTMLInputElement>('input[name="skills-filter"]');
140141
expect(selector).toBeInstanceOf(HTMLSelectElement);
142+
expect(filter).toBeInstanceOf(HTMLInputElement);
143+
expect(normalizeText(selector!.closest("label")!)).toContain("Agent");
144+
expect(normalizeText(filter!.closest("label")!)).toContain("Search");
141145
expect(selector?.value).toBe("research");
142146
expect(Array.from(selector!.options).map((option) => option.textContent?.trim())).toEqual([
143147
"Main (default)",

ui/src/pages/skills/view.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ export function renderSkills(props: SkillsProps) {
263263
${agents.length > 0
264264
? html`
265265
<label class="field" style="min-width: 180px;">
266-
<span>${t("common.filters.agent")}</span>
266+
<span>${t("usage.filters.agent")}</span>
267267
<select
268268
name="skills-agent"
269269
.value=${selectedAgentId}
@@ -283,6 +283,7 @@ export function renderSkills(props: SkillsProps) {
283283
`
284284
: nothing}
285285
<label class="field" style="flex: 1; min-width: 180px;">
286+
<span>${t("common.search")}</span>
286287
<input
287288
.value=${props.filter}
288289
@input=${(e: Event) => props.onFilterChange((e.target as HTMLInputElement).value)}

ui/src/styles/components.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,11 @@
940940
box-shadow var(--duration-fast) ease;
941941
}
942942

943+
.field input:not([type="checkbox"]):not([type="radio"]),
944+
.field select {
945+
height: 38px;
946+
}
947+
943948
@media (hover: none) and (pointer: coarse) {
944949
.field input,
945950
.field textarea,

0 commit comments

Comments
 (0)