-
Notifications
You must be signed in to change notification settings - Fork 6
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
toucan-form: Expose named blocks for textarea #149
toucan-form: Expose named blocks for textarea #149
Conversation
|
Preview URLsEnv: preview |
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 described the issue in the comment here, but TL;DR:
The issue is we cannot do something like:
<@form.Field @name={{@name}} as |field|>
<Form::Fields::Textarea
@hint={{@hint}}
@error={{this.mapErrors field.rawErrors}}
@value={{this.assertString field.value}}
{{! @glint-expect-error }}
@onChange={{field.setValue}}
@isDisabled={{@isDisabled}}
@isReadOnly={{@isReadOnly}}
@rootTestSelector={{@rootTestSelector}}
name={{@name}}
...attributes
>
{{#if (has-block 'label')}}
<:label>{{yield to='label'}}</:label>
{{/if}}
</Form::Fields::Textarea>
</@form.Field>
Or else we get the following due to emberjs/rfcs#735:
Build Error (PackagerRunner) in ../packages/ember-toucan-form/dist/-private/textarea-field.js
Module build failed (from ember-toucan-core/node_modules/.pnpm/[email protected][email protected]/node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 5)
$TMPDIR/embroider/835ae7/packages/ember-toucan-form/dist/-private/textarea-field.js/textarea-field.js: Unexpected named block nested in a normal block:
|
|
| <:label>{{yield to='label'}}</:label>
|
|
(error occurred in '$TMPDIR/embroider/835ae7/packages/ember-toucan-form/dist/-private/textarea-field.js' @ line 33 : column 31)
Essentially we have two layers of named blocks here:
- In
Form::Fields::Textarea
- this is the source of the named blocks - When users use our
<form.Textarea
component intoucan-form
Due to this nesting, essentially passing blocks from a higher level component to a lower level one does not work as you'd expect. We essentially need something like splat-blocks or something I think to solve this?
test-app/tests/integration/components/toucan-form/form-textarea-test.gts
Outdated
Show resolved
Hide resolved
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 agree the implementation does not really look beautiful, but that's not our fault. We already used some "wilder" patterns that are making things easy and powerful at the same time for consumers while accepting increased complexity on our (library maintainers) side. And I think that choice is reasonable here.
cf7599a
to
85e9e76
Compare
…a-test.gts Co-authored-by: nicole chung <[email protected]>
Thanks y'all for the feedback and discussion. I went ahead and created |
🚀 Description
This PR attempts to expose all named blocks from textarea within toucan-form. This is more of a conversation PR to see if we want to go with this approach due to the limitations with named blocks.
Depending on how this goes, I'll update all the other components as well (maybe via a feature branch for smaller PRs).
🔬 How to Test
📸 Images/Videos of Functionality
M/A