From b7b24e5de339f04612e4a67cabe3142ddb79a7e4 Mon Sep 17 00:00:00 2001 From: SHAIK KHADEER BASHA <120262074+KhadeerBasha1232@users.noreply.github.com> Date: Fri, 4 Dec 2026 23:36:00 +0530 Subject: [PATCH] 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. --- CHANGELOG.md | 1 + e2e/layer-editor.spec.ts | 8 ++++++++ e2e/maputnik-driver.ts | 4 ++++ src/components/InputColor.tsx | 2 +- src/styles/_input.scss | 1 + 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f401bfe..b495c8a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ ### 🐞 Bug fixes - Keep the color picker within the viewport when opening it near an edge, scrolling, or resizing. +- Open the color picker when clicking a color field's swatch, not only its text input. - Apply layer renames when pressing Enter or leaving the ID field to avoid validating and saving the style on every keystroke. - Add distinct screen reader labels for the anchor, X offset, and Y offset in each variable anchor offset row. - Open `icon-padding` expressions in the expression editor so they can be viewed and edited. diff --git a/e2e/layer-editor.spec.ts b/e2e/layer-editor.spec.ts index 07e7449a..5d1d8b00 100644 --- a/e2e/layer-editor.spec.ts +++ b/e2e/layer-editor.spec.ts @@ -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); diff --git a/e2e/maputnik-driver.ts b/e2e/maputnik-driver.ts index 6f8e7c57..6401af7d 100644 --- a/e2e/maputnik-driver.ts +++ b/e2e/maputnik-driver.ts @@ -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" })); diff --git a/src/components/InputColor.tsx b/src/components/InputColor.tsx index 4b570e8a..63e173b4 100644 --- a/src/components/InputColor.tsx +++ b/src/components/InputColor.tsx @@ -163,7 +163,7 @@ export class InputColor extends React.Component {this.state.pickerOpened && picker} -
+