Clear the editor when clicking on the active bang.
This commit is contained in:
parent
d66b43e9fd
commit
28123cfb3f
|
@ -120,9 +120,18 @@ export class PageMain extends Component<Props, State> {
|
||||||
const availableBangs = bangs.map((bang) => {
|
const availableBangs = bangs.map((bang) => {
|
||||||
const active = bang.id === this.state.editorBang.id ? 'active' : '';
|
const active = bang.id === this.state.editorBang.id ? 'active' : '';
|
||||||
const onClick = () => {
|
const onClick = () => {
|
||||||
|
const allEqual = Object.entries(this.state.editorBang).every(
|
||||||
|
([key, value]) => bang[key as keyof BangParameters] === value,
|
||||||
|
);
|
||||||
|
if (allEqual) {
|
||||||
|
this.setState({
|
||||||
|
editorBang: {...this.emptyBang},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
editorBang: {...bang},
|
editorBang: {...bang},
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
|
|
Loading…
Reference in New Issue