-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Components using text-support mixin do not work native class actions correctly #18994
Comments
Thanks for reporting! When you work on the PR, can you add tests for both |
Will do! |
kategengler
pushed a commit
that referenced
this issue
Jun 1, 2020
The introduction of the `attrs` API in Ember 3.13 included wrapping items passed to components with `MutableCell`, to support two-way binding. Although two-way binding is gone from much of Ember, the text input components (`Input` and `Textarea`) continue to support it, via the `TextSupport` mixins. The `sendAction` function used by the mixin previously assumed that the only options were for an action to be a string or a function -- not a function wrapped in a `MutableCell`. The result was that this code, which would be expected to work, did not: it would simply never be invoked. <Textarea @Focus-In={{this.didFocusIn}} /> Accordingly, add logic to `sendAction` in `text_support.js` to unwrap a mutable cell if it is set, and otherwise to carry on with the logic as it was previously. Resolves #18994 (cherry picked from commit f16d174)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A simple reproduction:
It does work if you instead invoke—
with
{{fn}}
:with
{{action}}
:with
{{action}}
and a string name:The problem is here:
ember.js/packages/@ember/-internals/views/lib/mixins/text_support.js
Lines 309 to 327 in 8cf2995
The key is that we look up the value from
attrs
first, andattrs
always ends up with arguments wrapped inMutableCell
(to support two-way binding), so the check whethertypeof
the action is"function"
always fails (it's"object"
instead). There is special handling for{{action}}
and{{fn}}
so they don't have this, which is why using them works.We need to make sure we explicitly handle the case where the item is a
MutableCell
, and having done so we'll be able to correctly "fallback" for normal method-style actions.cc. @rwjblue. I'll try to have a PR up for this tomorrow morning, with a test for the failure case and a fix.
The text was updated successfully, but these errors were encountered: