feat: Add BooleanMetaDataField to support checkbox inputs on sign-up form #115
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
This commit adds a new
BooleanMetaDataField
class to support checkbox inputsin the
SupaEmailAuth
component for boolean metadata. This enhancement allows for more versatile formcreation, particularly useful for consent checkboxes or boolean preferences.
Resolves #96
Key changes:
New
BooleanMetaDataField
class:MetaDataField
to maintain compatibilityUpdates to
SupaEmailAuth
:MetaDataField
andBooleanMetaDataField
Styling:
Documentation:
BooleanMetaDataField
Example updates:
BooleanMetaDataField
Backward compatibility:
MetaDataField
usageThis enhancement provides developers with more flexibility in creating
sign-up forms, particularly for scenarios requiring user consent or
boolean preferences, while maintaining the existing functionality
of the
SupaEmailAuth
component.Additional context
There's quite a lot here, so while I've supplied screenshots, I recommend viewing the change in the example app to get a sense of its behavior. Don't hesitate to push back or question any decisions I made.
There are two specific issues that I would like feedback on before this PR gets approved, since any future changes to
BooleanMetaDataField
could be breaking:richLabel
property that took a singleRichText
widget, but that won't match the styling of the other components on the form unless users of this library match it themselves. It felt too customizable, when all that the class really needs is a list of text widgets so it can arrange them like:"".
So I modified it to instead take a
List<InlineSpan>
, and keep theRichText
widget internal and give it a default style that matches the other fields in the form. If needed, the style can be overridden in the widgets that are passed in (for example, making a link blue).BooleanMetaDataField
will focus like any other field in the form, and when selected, thelabel
orsemanticsLabel
will be read aloud appropriately.The only issue I had was getting the screen reader to select and read aloud any links or interactive text within the
richLabelSpan
. The ideal (and expected) behavior would be:I wanted this to work out of the box, but it was a bit more difficult than I anticipated. Only step one works. Pressing tab again will focus on the next form component or the submit button.
I eventually got the subtext focusable, but I was never able to get the screen reader to read it aloud. The further I got into making that work, the more complex this change got, and after a certain point it just seemed out of scope. I have a lengthy change stashed on my fork that almost works, but for now I think users of this library will have to handle accessibility themselves for whatever widgets are passed in to
richLabelSpan
. If I figure out a clean and easily-maintainable way to handle it, I'll submit another PR.Screenshots
Desktop:
Mobile: