mirror of
https://github.com/maputnik/editor.git
synced 2026-11-30 13:54:20 +00:00
Fixes #747 Boolean properties that default to `true` (`fill-antialias`, `text-keep-upright`, `fill-extrusion-vertical-gradient`) showed an empty checkbox when unset, so the first click wrote `true` and nothing changed on the map. `InputCheckbox` now falls back to the spec default that `InputSpec` already passes (as `InputEnum` does), and a click toggles from what is shown. The Cluster checkbox in the sources modal passes no default, so it behaves as before. ## Launch Checklist - [x] Briefly describe the changes in this PR. - [x] Link to related issues. - [x] Include before/after visuals or gifs if this PR includes visual changes. - [x] Write tests for all new functionality. - [x] Add an entry to `CHANGELOG.md` under the `## main` section. Added two e2e tests on `fill-antialias` (checked when unset, one click writes `false`). ## Screenshots "Extrusion vertical gradient" on a `fill-extrusion` layer with the property unset, before and after: | Before | After | | --- | --- | |  |  | |  |  | ## Video The video shows the same row on a small extrusion style, and one click turning the gradient off. https://github.com/user-attachments/assets/8ebc2f5a-923b-4022-82da-07cbd1eda783 Fix written with Claude Code; video is an automated browser run of this branch recorded by User Stories Bot.
40 lines
992 B
TypeScript
40 lines
992 B
TypeScript
import React from "react";
|
|
|
|
export type InputCheckboxProps = {
|
|
value?: boolean
|
|
default?: boolean
|
|
style?: object
|
|
onChange(...args: unknown[]): unknown
|
|
};
|
|
|
|
export class InputCheckbox extends React.Component<InputCheckboxProps> {
|
|
isChecked() {
|
|
return this.props.value ?? this.props.default ?? false;
|
|
}
|
|
|
|
onChange = () => {
|
|
this.props.onChange(!this.isChecked());
|
|
};
|
|
|
|
render() {
|
|
const checked = this.isChecked();
|
|
return <div className="maputnik-checkbox-wrapper">
|
|
<input
|
|
className="maputnik-checkbox"
|
|
type="checkbox"
|
|
style={this.props.style}
|
|
onChange={this.onChange}
|
|
onClick={this.onChange}
|
|
checked={checked}
|
|
/>
|
|
<div className="maputnik-checkbox-box">
|
|
<svg style={{
|
|
display: checked ? "inline" : "none"
|
|
}} className="maputnik-checkbox-icon" viewBox='0 0 32 32'>
|
|
<path d='M1 14 L5 10 L13 18 L27 4 L31 8 L13 26 z' />
|
|
</svg>
|
|
</div>
|
|
</div>;
|
|
}
|
|
}
|