Skip to content

Commit

Permalink
Fix clicking description to toggle checkbox - #106897
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Sep 23, 2020
1 parent 8c2e1bf commit 49225a4
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/vs/workbench/contrib/preferences/browser/settingsTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1438,21 +1438,17 @@ export class SettingBoolRenderer extends AbstractSettingRenderer implements ITre
controlElement.appendChild(checkbox.domNode);
toDispose.add(checkbox);
toDispose.add(checkbox.onChange(() => {
if (template.onChange) {
template.onChange(checkbox.checked);
}
template.onChange!(checkbox.checked);
}));

// Need to listen for mouse clicks on description and toggle checkbox - use target ID for safety
// Also have to ignore embedded links - too buried to stop propagation
toDispose.add(DOM.addDisposableListener(descriptionElement, DOM.EventType.MOUSE_DOWN, (e) => {
const targetElement = <HTMLElement>e.target;
const targetId = descriptionElement.getAttribute('checkbox_label_target_id');

// Make sure we are not a link and the target ID matches
// Toggle target checkbox
if (targetElement.tagName.toLowerCase() !== 'a' && targetId === template.checkbox.domNode.id) {
template.checkbox.checked = template.checkbox.checked ? false : true;
if (targetElement.tagName.toLowerCase() !== 'a') {
template.checkbox.checked = !template.checkbox.checked;
template.onChange!(checkbox.checked);
}
DOM.EventHelper.stop(e);
Expand Down

0 comments on commit 49225a4

Please sign in to comment.