mirror of
https://github.com/maputnik/editor.git
synced 2026-12-05 16:24:20 +00:00
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:
1 parent
26a909ced7
commit
b7b24e5de3
5 files changed
+15
-1
No files matched your search
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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" }));
|
||||
|
||||
@@ -163,7 +163,7 @@ export class InputColor extends React.Component<InputColorProps, InputColorState
|
||||
|
||||
return <div className="maputnik-color-wrapper">
|
||||
{this.state.pickerOpened && picker}
|
||||
<div className="maputnik-color-swatch" style={swatchStyle}></div>
|
||||
<div className="maputnik-color-swatch" style={swatchStyle} onClick={this.togglePicker} aria-hidden="true"></div>
|
||||
<input
|
||||
aria-label={this.props["aria-label"]}
|
||||
spellCheck="false"
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
width: 14px;
|
||||
flex-shrink: 0;
|
||||
flex-grow: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
// ARRAY
|
||||
|
||||
Reference in new issue
Block a user