Skip to content

Commit 0980d98

Browse files
committed
Fixes check state for checkboxes
1 parent 9f4cd3a commit 0980d98

File tree

3 files changed

+21
-23
lines changed

3 files changed

+21
-23
lines changed

src/webviews/apps/plus/graph/GraphWrapper.tsx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,7 @@ export function GraphWrapper({
13531353
<GlCheckbox
13541354
value="onlyFollowFirstParent"
13551355
onChange={handleFilterChange}
1356-
defaultChecked={graphConfig?.onlyFollowFirstParent ?? false}
1356+
checked={graphConfig?.onlyFollowFirstParent ?? false}
13571357
>
13581358
Simplify Merge History
13591359
</GlCheckbox>
@@ -1364,7 +1364,7 @@ export function GraphWrapper({
13641364
<GlCheckbox
13651365
value="remotes"
13661366
onChange={handleFilterChange}
1367-
defaultChecked={excludeTypes?.remotes ?? false}
1367+
checked={excludeTypes?.remotes ?? false}
13681368
>
13691369
Hide Remote-only Branches
13701370
</GlCheckbox>
@@ -1373,7 +1373,7 @@ export function GraphWrapper({
13731373
<GlCheckbox
13741374
value="stashes"
13751375
onChange={handleFilterChange}
1376-
defaultChecked={excludeTypes?.stashes ?? false}
1376+
checked={excludeTypes?.stashes ?? false}
13771377
>
13781378
Hide Stashes
13791379
</GlCheckbox>
@@ -1384,7 +1384,7 @@ export function GraphWrapper({
13841384
<GlCheckbox
13851385
value="tags"
13861386
onChange={handleFilterChange}
1387-
defaultChecked={excludeTypes?.tags ?? false}
1387+
checked={excludeTypes?.tags ?? false}
13881388
>
13891389
Hide Tags
13901390
</GlCheckbox>
@@ -1394,7 +1394,7 @@ export function GraphWrapper({
13941394
<GlCheckbox
13951395
value="mergeCommits"
13961396
onChange={handleFilterChange}
1397-
defaultChecked={graphConfig?.dimMergeCommits ?? false}
1397+
checked={graphConfig?.dimMergeCommits ?? false}
13981398
>
13991399
Dim Merge Commit Rows
14001400
</GlCheckbox>
@@ -1474,7 +1474,7 @@ export function GraphWrapper({
14741474
<GlCheckbox
14751475
value="localBranches"
14761476
onChange={handleOnMinimapAdditionalTypesChange}
1477-
defaultChecked={
1477+
checked={
14781478
graphConfig?.minimapMarkerTypes?.includes('localBranches') ?? false
14791479
}
14801480
>
@@ -1489,7 +1489,7 @@ export function GraphWrapper({
14891489
<GlCheckbox
14901490
value="remoteBranches"
14911491
onChange={handleOnMinimapAdditionalTypesChange}
1492-
defaultChecked={
1492+
checked={
14931493
graphConfig?.minimapMarkerTypes?.includes('remoteBranches') ?? true
14941494
}
14951495
>
@@ -1504,7 +1504,7 @@ export function GraphWrapper({
15041504
<GlCheckbox
15051505
value="pullRequests"
15061506
onChange={handleOnMinimapAdditionalTypesChange}
1507-
defaultChecked={
1507+
checked={
15081508
graphConfig?.minimapMarkerTypes?.includes('pullRequests') ?? true
15091509
}
15101510
>
@@ -1519,9 +1519,7 @@ export function GraphWrapper({
15191519
<GlCheckbox
15201520
value="stashes"
15211521
onChange={handleOnMinimapAdditionalTypesChange}
1522-
defaultChecked={
1523-
graphConfig?.minimapMarkerTypes?.includes('stashes') ?? false
1524-
}
1522+
checked={graphConfig?.minimapMarkerTypes?.includes('stashes') ?? false}
15251523
>
15261524
<span className="minimap-marker-swatch" data-marker="stashes"></span>
15271525
Stashes
@@ -1531,9 +1529,7 @@ export function GraphWrapper({
15311529
<GlCheckbox
15321530
value="tags"
15331531
onChange={handleOnMinimapAdditionalTypesChange}
1534-
defaultChecked={
1535-
graphConfig?.minimapMarkerTypes?.includes('tags') ?? true
1536-
}
1532+
checked={graphConfig?.minimapMarkerTypes?.includes('tags') ?? true}
15371533
>
15381534
<span className="minimap-marker-swatch" data-marker="tags"></span>
15391535
Tags

src/webviews/apps/shared/components/checkbox/checkbox.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { html } from 'lit';
2-
import { customElement, property, state } from 'lit/decorators.js';
3-
import { when } from 'lit/directives/when.js';
2+
import { customElement, property } from 'lit/decorators.js';
43
import { GlElement, observe } from '../element';
54
import { checkboxBaseStyles } from '../forms/checkbox.css';
65
import { checkboxStyles } from './checkbox.css';
@@ -18,22 +17,25 @@ export class Checkbox extends GlElement {
1817

1918
static override readonly styles = [checkboxBaseStyles, checkboxStyles];
2019

21-
@property({ type: Boolean })
22-
disabled: boolean;
20+
@property({ type: Boolean, reflect: true })
21+
disabled: boolean = false;
2322

2423
@property({ type: String })
2524
value: string = '';
2625

26+
_defaultChecked: boolean = false;
2727
@property({ type: Boolean })
28-
defaultChecked: boolean = false;
28+
get defaultChecked() {
29+
return this._defaultChecked;
30+
}
2931

30-
@state()
31-
checked: boolean;
32+
@property({ type: Boolean, reflect: true })
33+
checked: boolean = false;
3234

3335
constructor() {
3436
super();
3537
this.disabled = false;
36-
this.checked = this.defaultChecked;
38+
this._defaultChecked = this.checked;
3739
}
3840

3941
@observe(['defaultChecked'], { afterFirstUpdate: true })

src/webviews/apps/shared/components/radio/radio.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class Radio extends GlElement {
2727
@property({ type: String, reflect: true })
2828
name?: string;
2929

30-
@property({ type: Boolean, attribute: false })
30+
@property({ type: Boolean, reflect: true })
3131
checked: boolean = false;
3232

3333
private _parentGroup: RadioGroup | undefined = undefined;

0 commit comments

Comments
 (0)