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

refactor: use ItemNavigation optimally #2585

Merged
merged 1 commit into from
Dec 16, 2020

Conversation

vladitasev
Copy link
Contributor

@vladitasev vladitasev commented Dec 16, 2020

This change refactors the usage of ItemNavigation.js for all components except date/time related ones (which will be addressed separately).

Changes:

  • Now that getItemsCallback can be set in the constructor, this is the preferable way of passing it. This also eliminates the need of a separate initItemNavigation function that many components had as they needed 2 lines of code - new ItemNavigation and to set the callback.
  • Implement the focusin event for Timeline.js as it did not update the item navigation like the rest of the components whenever the user clicks with the mouse.
  • Do not use ItemNavigation.prototype.current any more (it is marked as deprecated). Always call update instead.
  • Do not use ItemNavigation.prototype.currentIndex any more (it is private). Always call update instead.
  • Do not use ItemNavigation.prototype.focusCurrent any more (marked as deprecated). Use the item that was passed to update directly (see Tokenizer.js for example).
  • Do not re-initialize getItemsCallback in onBeforeRendering - it is a callback exactly for the reason that based on the state of the component, it may return completely different data (see AvatarGroup.js for an example)

Summary:

  • Initialize ItemNavigation in the constructor of the component and pass the callback there
  • Implement a focusin event for your component and call update with the newly focused item to synchronize the item navigation. Do not use current or currentIndex.

@vladitasev vladitasev merged commit 283e9db into master Dec 16, 2020
@vladitasev vladitasev deleted the improve-item-navigation-usage branch December 16, 2020 13:56
niyap pushed a commit to niyap/ui5-webcomponents that referenced this pull request Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants