diff --git a/lib/KRadioButton.vue b/lib/KRadioButton.vue index ba5a00b01..f12cd3de7 100644 --- a/lib/KRadioButton.vue +++ b/lib/KRadioButton.vue @@ -185,6 +185,9 @@ "KRadioButton: 'value' prop is deprecated and will be removed in a future release. Please use 'buttonValue' instead." ); } + if (process.env.NODE_ENV !== 'production') { + this.checkForKRadioButtonGroup(); + } }, methods: { /** @@ -237,6 +240,18 @@ setTabIndex(val) { this.tabIndex = val; }, + + checkForKRadioButtonGroup() { + let parent = this.$parent; + while (parent) { + if (parent.$options.name === 'KRadioButtonGroup') { + return; // Found KRadioButtonGroup, no warning needed + } + parent = parent.$parent; + } + // If we get here, no KRadioButtonGroup was found + console.warn('KRadioButton should be nested inside a KRadioButtonGroup component.'); + }, }, };