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

Example of built-in component uses dasherized event #1485

Closed
Benjy1979 opened this issue Jul 19, 2020 · 7 comments
Closed

Example of built-in component uses dasherized event #1485

Benjy1979 opened this issue Jul 19, 2020 · 7 comments
Assignees

Comments

@Benjy1979
Copy link

Benjy1979 commented Jul 19, 2020

At https://guides.emberjs.com/v3.19.0/components/built-in-components/

there is as an example immediately under the "Actions" header:

First Name
<Input @value={{this.firstName}} @key-down={{this.updateFirstName}} id="firstname" />

But then later in the page:
{{!-- This does not work: uses dasherized event name --}}
<Input @type="checkbox" @key-down={{this.updateName}} id="firstname" />
{{!-- This does not work: uses actual event name --}}
<Input @type="checkbox" @keydown={{this.updateName}} id="firstname" />

@ijlee2
Copy link
Member

ijlee2 commented Jul 19, 2020

Hi, @Benjy1979. Thanks for reporting this issue. Sorry if this was your first experience with Ember and the <Input> component didn't work as you expected.

To my understanding, we're currently unsure what causes the event arguments to not work sometimes. The issue's under investigation, albeit not actively:

I'll look into the ember.js repository to better understand how the <Input> component works. I can bring up the issue at this week's Learning Team meeting too.

Since this issue is close to the two above, is it okay with you if I close this one?

@Benjy1979
Copy link
Author

Benjy1979 commented Jul 19, 2020 via email

@ijlee2
Copy link
Member

ijlee2 commented Jul 19, 2020

Yep, I misunderstood your original message. I looked at https://guides.emberjs.com/v3.19.0/components/built-in-components/ and believe you were referring to these 2 parts, is this correct?

Part 1:

Screen Shot 2020-07-19 at 3 14 18 PM

Part 2:

Screen Shot 2020-07-19 at 3 06 45 PM

I looked at the relevant code in ember.js repo. It seems to me that the confusion with event argument names is due to how <Input> internally uses two different components: a <Checkbox> component when we pass the argument @type="checkbox", and a <TextField> component in all other cases. I believe both components rely on mixins to allow event handling, which adds to further confusion.

In short, I think the Built-in Components section currently does show the right information: "For @type="checkbox", use camel-cased event names, but for all other cases, dasherized names are okay."

This Thursday, at the Learning Team meeting, let me double-check with the rest of the team:

  • Is my conclusion above (in quotes) correct?
  • How can we explain better what event argument names to pass when creating (1) a checkbox input, (2) a non-checkbox input, and (3) a textarea?

@Benjy1979
Copy link
Author

Benjy1979 commented Jul 19, 2020 via email

@ijlee2
Copy link
Member

ijlee2 commented Aug 6, 2020

@Benjy1979 Hello! I want to give a status update.

Today at the Learning Team meeting, I brought up the user experience that you had with reading the Guides to learn event handling for a checkbox input. Everyone was on board with reorganizing the section to help explain event handling better.

https://github.com/emberjs/core-notes/pull/322/files#diff-1c6fe35708f8b2c2b915bde415dfce75R52

When I can find time this month, I can work on addressing and closing this issue. Would this be okay with you?

@Benjy1979
Copy link
Author

Of course, thanks for giving it some attention.

@ijlee2
Copy link
Member

ijlee2 commented Sep 24, 2020

Let me close this in favor of #1540.

@ijlee2 ijlee2 closed this as completed Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants