Skip to content

Commit 44ac386

Browse files
committed
fix(MenuToggle): fixed possible error when setting indeterminet state of menu toggles
1 parent ac41a54 commit 44ac386

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/core/src/components/MenuToggle/MenuToggleCheckbox.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<label v-bind="(ouiaProps as any)" :class="styles.check">
33
<input
44
v-bind="$attrs"
5-
:ref="(el) => (el as HTMLInputElement).indeterminate = checked === null"
5+
:ref="(el) => setIndeterminateState(el)"
66
:class="styles.checkInput"
77
type="checkbox"
88
:checked="Boolean(checked)"
@@ -12,7 +12,7 @@
1212

1313
<script lang="ts" setup>
1414
import styles from '@patternfly/react-styles/css/components/Check/check';
15-
import { type InputHTMLAttributes } from 'vue';
15+
import { type ComponentPublicInstance, type InputHTMLAttributes } from 'vue';
1616
import { useOUIAProps, type OUIAProps } from '../../helpers/ouia';
1717
1818
defineOptions({
@@ -30,4 +30,10 @@ const props = defineProps<Props>();
3030
defineSlots<Record<string, never>>();
3131
3232
const ouiaProps = useOUIAProps({id: props.ouiaId, safe: props.ouiaSafe});
33+
34+
function setIndeterminateState(el: Element | ComponentPublicInstance | null) {
35+
if (el instanceof HTMLInputElement) {
36+
el.indeterminate = props.checked === null;
37+
}
38+
}
3339
</script>

0 commit comments

Comments
 (0)