원클릭으로
handle-modus-checkbox-value-bug
Apply the critical checkbox value inversion workaround when working with ModusCheckbox components
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Apply the critical checkbox value inversion workaround when working with ModusCheckbox components
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Scaffold form components with proper Modus input integration, event handling, validation, and checkbox bug handling
Scaffold a new Modus wrapper component following established SolidJS patterns with proper TypeScript interfaces, event handling, and cleanup
Debug and fix common event handling problems with Modus web components
Create Modus modals using the callback ref pattern for programmatic control
Help with correct Modus icon usage patterns including naming conventions, sizing, and accessibility
Build production-grade frontend interfaces using the Modus 2.0 Design System with Tailwind CSS. Use this skill when the user asks to build web components, pages, dashboards, or application screens. Enforces the 9-color semantic system, Modus Web Components, Modus Icons, and design system compliance. Framework-agnostic (works with SolidJS, React, Angular, or any framework).
| name | handle-modus-checkbox-value-bug |
| description | Apply the critical checkbox value inversion workaround when working with ModusCheckbox components |
Apply the critical value inversion workaround for ModusWcCheckbox components.
The ModusWcCheckbox web component has a value inversion bug where the value property returns the opposite of the actual checked state:
target.value returns falsetarget.value returns trueThis is the opposite of what developers expect.
Use this skill when:
See src/components/ModusCheckbox.tsx for the complete workaround implementation.
Always invert the value when reading from checkbox events:
const handleValueChange = (event: Event) => {
const customEvent = event as CustomEvent<InputEvent>;
// 🚨 CRITICAL: Handle the value inversion bug
const rawValue = (customEvent.target as HTMLModusWcCheckboxElement).value;
const actualValue = !rawValue; // ✅ CORRECT: Invert the value
// Use actualValue for your logic
setChecked(actualValue);
};
import { createEffect } from "solid-js";
import type { Component } from "solid-js";
const ModusCheckbox: Component<{
value?: boolean;
onValueChange?: (event: CustomEvent<boolean>) => void;
}> = (props) => {
let checkboxEl: HTMLModusWcCheckboxElement | undefined;
createEffect(() => {
const checkbox = checkboxEl;
if (!checkbox) return;
const handleValueChange = (event: Event) => {
const customEvent = event as CustomEvent<InputEvent>;
// 🚨 CRITICAL BUG WORKAROUND: The ModusWcCheckbox component has a value
// inversion bug where the `value` property returns the opposite of the
// actual checked state. This function corrects this by inverting the
// raw value before passing it to the parent component.
const rawValue = (customEvent.target as HTMLModusWcCheckboxElement).value;
const actualValue = !rawValue; // ✅ CORRECT: Invert the value
const correctedEvent = new CustomEvent("valueChange", {
detail: actualValue,
bubbles: true,
cancelable: true,
});
props.onValueChange?.(correctedEvent);
};
if (props.onValueChange) {
checkbox.addEventListener("inputChange", handleValueChange);
}
return () => {
if (props.onValueChange) {
checkbox.removeEventListener("inputChange", handleValueChange);
}
};
});
return (
<modus-wc-checkbox
ref={(el) => (checkboxEl = el)}
value={props.value}
/>
);
};
When using checkboxes in forms:
function MyForm() {
const [agreeToTerms, setAgreeToTerms] = createSignal(false);
return (
<ModusCheckbox
value={agreeToTerms()}
onValueChange={(event) => {
// event.detail is already corrected (inverted)
setAgreeToTerms(event.detail);
}}
label="I agree to the terms and conditions"
/>
);
}
When handling multiple checkboxes:
function CheckboxGroup() {
const [checkboxes, setCheckboxes] = createSignal({
option1: false,
option2: true,
option3: false,
});
const handleCheckboxChange = (key: string, event: CustomEvent<boolean>) => {
// event.detail is already corrected
setCheckboxes((prev) => ({
...prev,
[key]: event.detail,
}));
};
return (
<>
<ModusCheckbox
value={checkboxes().option1}
onValueChange={(e) => handleCheckboxChange("option1", e)}
label="Option 1"
/>
<ModusCheckbox
value={checkboxes().option2}
onValueChange={(e) => handleCheckboxChange("option2", e)}
label="Option 2"
/>
<ModusCheckbox
value={checkboxes().option3}
onValueChange={(e) => handleCheckboxChange("option3", e)}
label="Option 3"
/>
</>
);
}
target.value: The inversion happens when reading event.target.value, not in event.detailModusCheckbox wrapper component already handles this, so if you're using the wrapper, you don't need to invert againsrc/components/ModusCheckbox.tsx - Complete wrapper implementation