-
Notifications
You must be signed in to change notification settings - Fork 6
Custom toolbar radio button #178
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
base: master
Are you sure you want to change the base?
Conversation
| --- | ||
| category: forms | ||
| title: Add Grouped Radio Buttons with Custom Toolbar Button | ||
| description: Create a custom toolbar item that programmatically places pre-grouped radio buttons with a single click, avoiding manual renaming. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does pre-grouped means here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It means radio buttons are created with the same formFieldName, so they automatically function as a group
| defaultValue: "1", | ||
| }, | ||
| ); | ||
| await instance!.create([radioWidget1, radioWidget2, formField]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ! here is the non-null assertion operator—it tells TypeScript "trust me, this isn't null." Since instance is typed as Instance | null, what's the intended behavior if it actually is null at this point? Should it:
- Fail loudly (current behavior with ! if null at runtime)
- Silently skip the call (use
?.) - Something else (explicit check with error message?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already worked on something similar btw: #155
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@veroo-m , if I correctly understood your comment, I've added an if (!instance) return. Is that right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eli7pm , I see that yours auto-groups them widgets during manual creation in Form Creator mode, while mine provides a toolbar button for programmatic placement of grouped radio buttons. I was reluctant at first to close this one, but I think they're both useful for different workflows + this one adapts Rahul's new Playground structure.
|
Tested with Miguel's project to test and it seems to be working |
Added an explicit if (!instance) return
0mar-K
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
Adding a new playground example demonstrating how to create a custom toolbar button that programmatically creates pre-grouped radio buttons with a single click.