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

fix(NcActionRadio): change modelValue to behave like NcCheckboxRadioSwitch #6264

Merged
merged 2 commits into from
Jan 27, 2025

Conversation

Antreesy
Copy link
Contributor

☑️ Resolves

  • v-model: Boolean is quite unusable for radio-buttons, as it should store selected value (one from many options)
  • Should be changed by developers when migrate from checked to v-model, apart from that works as before

🖼️ Screenshots

🏚️ Before 🏡 After
image image

🚧 Tasks

  • check if it's a breaking change
    • this.model = this.$refs.radio.checked is kept for backward compatibility

🏁 Checklist

  • ⛑️ Tests are included or are not applicable
  • 📘 Component documentation has been extended, updated or is not applicable
  • 3️⃣ Backport to next requested with a Vue 3 upgrade

@Antreesy Antreesy added bug Something isn't working 3. to review Waiting for reviews feature: actions Related to the actions components labels Nov 25, 2024
@Antreesy Antreesy added this to the 8.21.1 milestone Nov 25, 2024
@Antreesy Antreesy requested a review from ShGKme November 25, 2024 11:09
@Antreesy Antreesy self-assigned this Nov 25, 2024
@susnux susnux modified the milestones: 8.21.1, 8.23.0 Jan 15, 2025
@Antreesy Antreesy requested a review from susnux January 21, 2025 17:42
Copy link
Contributor

@susnux susnux left a comment

Choose a reason for hiding this comment

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

Makes sense from my point of view and probably makes usage simpler

@Antreesy Antreesy force-pushed the fix/noid/action-radio-vmodel branch from 0385abf to 1c50065 Compare January 27, 2025 12:19
Signed-off-by: Maksim Sukharev <[email protected]>
@Antreesy
Copy link
Contributor Author

/backport to next

@Antreesy Antreesy merged commit 5488eb4 into master Jan 27, 2025
23 checks passed
@Antreesy Antreesy deleted the fix/noid/action-radio-vmodel branch January 27, 2025 12:32
Comment on lines +113 to +114
type: [String, Number],
default: '',
Copy link
Contributor

Choose a reason for hiding this comment

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

💥 This is a breaking change

Suggested change
type: [String, Number],
default: '',
type: [Boolean, String, Number],
default: false,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can emphasise more on it in the Changelog, but I'd address this as bug:

According to docs, type checkbox can have Boolean or String[], but type radio does not support it, and it should be String:
https://vuejs.org/guide/essentials/forms#radio
https://vuejs.org/guide/essentials/forms#value-bindings

I also tried to revert changes and experiment, boolean v-model does not change its value in that case:
image

Comment on lines +196 to +200
if (this.checked !== undefined) {
this.model = this.$refs.radio.checked
} else {
this.model = this.value
}
Copy link
Contributor

Choose a reason for hiding this comment

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

v-model="model" already handles change event and sets new this.model value which results in emitting the value.

It's handled twice now. Please, make sure it's correct, and no extra event is emitted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed. Difference with old implementation (adding that to the bug description):

Event Before After
@update:* true prop value
@change Event Event

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug Something isn't working feature: actions Related to the actions components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants