question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

live input update, immutable data, handleChange and Ember rerender

See original GitHub issue

Hello,

It is not a bug, but a feature request.

I have a problem when I update

  • a property
  • of an item
  • of a list in the state

by an input field

state
  |- list
       |- * item
{{#each list as |item|}}
  {{input value=item.value key-press=(action update_item_value)}}
  {{!-- trivial version just to understand my problem --}}
{{/each}}

=> the current component and all the parent components and pages are updated, because the state object is updated (it is immutable)

=> and so the {{#each}} helper refreshed the components of the list as well

=> and so the input is refreshed AND I LOOSE THE CURSOR POSITION !

Ember is not like ReactJS: without virtual hierarchy to compare, the real components are updated.

In connect > handleChange, we just check if the value of the property was changed, and when a property of an item of a list is changed, the list is changed too, so ember-redux notify this change.

So how to avoid to refresh everything ?

Thanks

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
wooandoocommented, Feb 19, 2017

Hello,

With the solution of @sandersky, it works: https://ember-twiddle.com/ebfa40f96ba41659765a09b3715587c1/cffae11937938d033482c0cbb5c83ad85f350797?openFiles=components.my-list.js%2C

The first list has the “key” defined, and not the second one.

Thanks.

Frédéric

1reaction
sanderskycommented, Feb 18, 2017

@wooandoo is there a unique identifier property on your list items that would allow you to do something like this:

{{#each list key='myUniqueProperty' as |item|}}
  {{input value=item.value key-press=(action update_item_value)}}
  {{!-- trivial version just to understand my problem --}}
{{/each}}

If so, I’m curious if that would solve the issue you are seeing or if the issue still persists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Component Lifecycle - Ember Guides
didUpdateAttrs runs when the attributes of a component have changed, but not when the component is re-rendered, via component.rerender , component.set ...
Read more >
Ember component is not re-rendering on change of @tracked ...
I expect it to refresh when action saveRoles(updatedUserRoles) is used, since it depends on an @tracked variable. UserRoles is a component from ...
Read more >
each re-render bug · Issue #16975 · emberjs/ember.js - GitHub
I have an array of true/false/undefined values which I am rendering as a list of checkboxes. When changing an array element to or...
Read more >
Understanding Ember.js: The View Layer - GitHub Pages
This guide goes into extreme detail about the Ember.js view layer. ... as well as updating the contents of the DOM when the...
Read more >
Top 65 React Interview Questions (2023) - Javatpoint
JSX; Components; One-way Data Binding; Virtual DOM; Simplicity; Performance ... Once the calculations are completed, the real DOM updated with only those ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found