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

feat(RadioGroup): Add selected binding #1587

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

simoncdn
Copy link
Sponsor Contributor

@simoncdn simoncdn commented Mar 30, 2024

πŸ”— Linked issue

Resolves #1563

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

The idea is to create a binding name 'selected' that returns a boolean if a radio is selected or not.
So I've created a new function named: guessOptionSelected(option: any) and passed it as a value of the key "selected" in the return of normalizeOptions function.
Then I've created a bind 'selected: option.selected' in the slot.

Code example:
Screenshot 2024-03-29 at 19 09 53
Video example:
https://github.com/nuxt/ui/assets/105924355/e6a07932-a7d7-4fbf-bcba-c415fff1beb8

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@@ -18,7 +18,7 @@
@change="onUpdate(option.value)"
>
<template #label>
<slot name="label" v-bind="{ option }" />
<slot name="label" v-bind="{ option, selected: option.selected }" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to inject the selected in every option? You could just have it globally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

selected property in RadioGroup #label slot
2 participants