Open the color picker from the color swatch (#2406)

Fixes the second part of #677 ("clicking the swatch should open the
color picker").

Only the text input next to a color swatch opened the picker; the swatch
itself did nothing when clicked. The swatch now opens and closes the
picker the same way, and shows a pointer cursor. It's `aria-hidden`,
since the text input stays the control that screen readers and the
keyboard use.

I left the first part of the issue, the swatch's border and inset,
alone. The thread didn't settle on one look for that.

**Before / after:** no visual change other than the pointer cursor over
the swatch; clicking it now opens the same picker the input opens.

**Performance:** no impact. It adds one click handler per color field.

## Launch Checklist

 - [x] Briefly describe the changes in this PR.
 - [x] Link to related issues: part of #677.
- [x] Include before/after visuals or gifs if this PR includes visual
changes: no visual change apart from the cursor.
- [x] Write tests for all new functionality: `opens the color picker
when the color swatch is clicked` in `layer-editor.spec.ts`, with a
`clickColorSwatch` driver action. It fails on `main`.
 - [x] Add an entry to `CHANGELOG.md` under the `## main` section.

Tested locally: `npm run lint` clean, `npx tsc --noEmit` clean, `npx
vitest run` (57 passed) and the full `npx playwright test` suite: 217
passed, and the 4 that failed were Data Sources tests that hit
`ERR_NETWORK_IO_SUSPENDED` while my PC slept. `modals.spec.ts` then
passed in full on a rerun (64 passed). The new test fails when I put
back `main`'s `InputColor.tsx`.

Assisted-By: Claude Opus 5.5 (Claude Code). It helped write the change,
the test and this description. I've reviewed and tested the change and
can answer questions about it.
This commit is contained in:
SHAIK KHADEER BASHA authored and GitHub committed 2026-12-04 20:06:00 +02:00
1 parent 26a909ced7
commit b7b24e5de3
5 files changed
+15 -1

No files matched your search

+8
View File
@@ -178,6 +178,14 @@ describe("layer editor", () => {
});
});
test("opens the color picker when the color swatch is clicked, same as the text input", async () => {
const bgId = await createBackground();
await when.click("layer-list-item:background:" + bgId);
await when.clickColorSwatch("background-color");
await then(get.colorPicker()).shouldBeVisible();
});
test("keeps the whole color picker visible when opened near the bottom", async () => {
const bgId = await createBackground();
await when.click("layer-list-item:background:" + bgId);
+4
View File
@@ -377,6 +377,10 @@ export class MaputnikDriver {
await this.helper.get.elementByTestId("spec-field:" + fieldName).locator(".maputnik-color").click();
},
clickColorSwatch: async (fieldName: string) => {
await this.helper.get.elementByTestId("spec-field:" + fieldName).locator(".maputnik-color-swatch").click();
},
openColorPickerAtBottom: async (fieldName: string) => {
const input = this.helper.get.elementByTestId("spec-field:" + fieldName).locator(".maputnik-color");
await input.evaluate(element => element.scrollIntoView({ block: "end" }));