Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Toggle the checkbox when clicking on the label

Kipras Melnikovas4e4ae0a7d05e
diff --git a/components/common/Checkbox.js b/components/common/Checkbox.js
index 67eea80d8..9b76e8053 100644
--- a/components/common/Checkbox.js
+++ b/components/common/Checkbox.js
@@ -7,12 +7,14 @@ import styles from './Checkbox.module.css';
function Checkbox({ name, value, label, onChange }) {
const ref = useRef();
+ const onClick = () => ref.current.click();
+
return (
<div className={styles.container}>
- <div className={styles.checkbox} onClick={() => ref.current.click()}>
+ <div className={styles.checkbox} onClick={onClick}>
{value && <Icon icon={<Check />} size="small" />}
</div>
- <label className={styles.label} htmlFor={name}>
+ <label className={styles.label} htmlFor={name} onClick={onClick}>
{label}
</label>
<input
diff --git a/components/common/Checkbox.module.css b/components/common/Checkbox.module.css
index 267a4054e..c9a01eacb 100644
--- a/components/common/Checkbox.module.css
+++ b/components/common/Checkbox.module.css
@@ -17,6 +17,7 @@
.label {
margin-left: 10px;
+ user-select: none; /* disable text selection when clicking to toggle the checkbox */
}
.input {