Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NcCheckboxRadioSwitch: Allow external label #5297

Open
hschletz opened this issue Feb 23, 2024 · 3 comments
Open

NcCheckboxRadioSwitch: Allow external label #5297

hschletz opened this issue Feb 23, 2024 · 3 comments
Labels
enhancement New feature or request feature: checkbox-radio-switch Related to the checkbox-radio-switch component

Comments

@hschletz
Copy link

I have a NcCheckboxRadioSwitch wrapped in an external label:

<label>
    <span>label</span>
    <NcCheckboxRadioSwitch type="switch" :checked.sync="value" />
</label>

This broke after a recent update. Clicking the switch has no effect. Clicking the label still toggles the switch.

I can work around the issue by using an id attribute:

<label :for="id">label</label>
<NcCheckboxRadioSwitch type="switch" :checked.sync="value" :id="id" />

but I'd rather prefer avoiding the hassle of generating unique ids for every form element.

@ShGKme
Copy link
Contributor

ShGKme commented Feb 23, 2024

It is supposed to be used as

<NcCheckboxRadioSwitch type="switch" :checked.sync="value">
  label
</NcCheckboxRadioSwitch>

Then it has common styles, focus effect, etc.

What is the use case to have the label outside the component?

@hschletz
Copy link
Author

hschletz commented Feb 26, 2024

I'm using the component as part of a large form with a custom layout (a grid with labels on the left and elements on the right). The default label placement, both by NcCheckboxRadioSwitch as well as other components like NcInputField, would not be suitable for this form. NcInputField and NcSelect support this via the labelOutside prop.

BTW, these components have the label provided as a prop, not as content. Wouldn't it be better to be consistent here?

@susnux
Copy link
Contributor

susnux commented Feb 29, 2024

While I agree that using the default slot for restricted content (text) is not good and would better fit in a label prop, I think in this case the idea was to have consistent styling across the components.

@susnux susnux added the enhancement New feature or request label Feb 29, 2024
@susnux susnux changed the title NcCheckboxRadioSwitch no longer clickable when wrapped in <label> NcCheckboxRadioSwitch: Allow external label Feb 29, 2024
@susnux susnux added the feature: checkbox-radio-switch Related to the checkbox-radio-switch component label Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature: checkbox-radio-switch Related to the checkbox-radio-switch component
Projects
None yet
Development

No branches or pull requests

3 participants