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

focus.one-time unexpected behaviour #273

Open
RomkeVdMeulen opened this issue Feb 6, 2017 · 2 comments
Open

focus.one-time unexpected behaviour #273

RomkeVdMeulen opened this issue Feb 6, 2017 · 2 comments

Comments

@RomkeVdMeulen
Copy link
Contributor

I'm submitting a bug report

  • Library Version:
    1.2.0

Please tell us about your environment:

  • Operating System:
    Linux (Ubuntu)

  • Node Version:
    6.9.4

  • NPM Version:
    3.10.10

  • JSPM
    JSPM 0.16.48

  • Browser:
    Chrome 55

  • Language:
    TypeScript 2.1.4

Current behavior:
If I want an element focused on render, but I'm not interested in keeping track of its focus state after that, I might do something like this:

<button focus.one-time="true">My Button</button>

In this case, attaching event listeners to the element only results in needless overhead.

Expected/desired behavior:
The Focus custom attribute should check if the binding mode is two-way and if not, should not attach event listeners to the element.

@RomkeVdMeulen
Copy link
Contributor Author

While we're on the subject: I would expect the default binding mode of focus to be one-way. I usually bind it to an expression that cannot be assigned to:

  <a href="#" focus.bind="item === defaultItem">${item.name}</a>

If focus changes and comes back to this link, I'll get an error:

Uncaught Error: Binding expression "item === defaultItem" cannot be assigned to.

I can't speak for other developers, but I expect the most common use-case for the focus attribute to set initial focus, not to keep a property updated on whether an item is focused or not.

@Alexander-Taran
Copy link

Alexander-Taran commented Mar 1, 2018

attach focus from dialog is what you want..
https://github.com/aurelia/dialog/blob/master/src/attach-focus.ts
question is how many developers thought about using focus.one-way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants