Skip to content

Commit b48fdde

Browse files
committed
table-of-contents: avoid two-way binding on Input
Let's avoid using the `Input` component, as this provides a two-way binding on the @checked argument. Let's use the regular `input` tag here with an `onchange` helper to handle the toggling event.
1 parent 216e230 commit b48fdde

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

app/components/table-of-contents.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@
3939
</li>
4040
</ol>
4141
<label class='toc-private-toggle'>
42-
<Input @type='checkbox' @checked={{@showPrivateClasses}} class='private-deprecated-toggle' />
42+
<input type='checkbox' checked={{@showPrivateClasses}} onchange={{@togglePrivateClasses}} class='private-deprecated-toggle' />
4343
Show Private / Deprecated
4444
</label>

app/controllers/project-version.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable ember/no-computed-properties-in-native-classes */
2-
import { computed } from '@ember/object';
2+
import { action, computed, set } from '@ember/object';
33
import { inject as service } from '@ember/service';
44
import { readOnly, alias } from '@ember/object/computed';
55
import Controller from '@ember/controller';
@@ -121,4 +121,9 @@ export default class ProjectVersionController extends Controller {
121121

122122
@readOnly('model.project.id')
123123
activeProject;
124+
125+
@action
126+
togglePrivateClasses() {
127+
set(this, 'showPrivateClasses', !this.showPrivateClasses);
128+
}
124129
}

app/templates/project-version.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
@moduleIDs={{this.shownModuleIDs}}
3535
@namespaceIDs={{this.shownNamespaceIDs}}
3636
@showPrivateClasses={{this.showPrivateClasses}}
37+
@togglePrivateClasses={{this.togglePrivateClasses}}
3738
@isShowingNamespaces={{version-lt this.selectedProjectVersion.compactVersion "2.16"}}
3839
/>
3940
</aside>

0 commit comments

Comments
 (0)