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

fix(react-core): prevent Getter losing on Plugin adding #2002

Conversation

DmitryBogomolov
Copy link
Contributor

@DmitryBogomolov DmitryBogomolov commented Apr 27, 2019

What happens

Plugin, Getter and Template have internal objects (this.plugin) which ordered within PluginHost internal object (this.plugins) based on corresponding positions.
Position originates from component index within its parent children.

For this tree

<PluginHost>
  <PluginA />
  <PluginC />
</PluginHost>

the list is the following

[ A(0), C(1) ]

When tree changes to

<PluginHost>
  <PluginA />
  <PluginB />
  <PluginC />
</PluginHost>

PluginB is created (internal object is created and added to list) and PluginC is updated (index changes).
During PluginB creation its internal object is created and has position (1). But PluginC is not updated by that moment and its internal object position is (1) too.
Such position collision is resolved in such a way that B(1) replaces C(1). The list is

[ A(0), B(1) ]

Here is a sample of React behavior.
Click the Change button and note that C2 and C3 are created C4 and C5 have outdated indexes.

What is done

  • key property is used to force recreation all items going after newly added
  • unregisterPlugin fixed so that it does not accidentally remove last list item

Because of key PluginC is destroyed (and C(1) is remove from list) and created (and C(2) is added to to list) after PluginB is created. So the list is

[ A(0), B(1), C(2) ]

Since registerPlugin allows the case when other list entry is removed (when there is position collision), unregisterPlugin should allow the case when no entry is removed (because it could already be removed in registerPlugin).

@DmitryBogomolov DmitryBogomolov changed the title fix(react-core): prevent Getter logins on Plugin adding fix(react-core): prevent Getter losing on Plugin adding Apr 27, 2019
@DmitryBogomolov
Copy link
Contributor Author

Fixes #1971.

@DmitryBogomolov DmitryBogomolov merged commit 89f4e87 into DevExpress:master Apr 30, 2019
@DmitryBogomolov DmitryBogomolov deleted the prevent-getter-losing-on-plugin-adding branch April 30, 2019 11:49
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

Successfully merging this pull request may close these issues.

5 participants