kolibri-design-system icon indicating copy to clipboard operation
kolibri-design-system copied to clipboard

[KTable]: Refactoring the handleKeydown method in KTable

Open BabyElias opened this issue 1 year ago • 4 comments

🌱 Are you new to the codebase? Welcome! Please see the contributing guidelines.

Summary

In #727, we introduced a new component—KTable—which provides a flexible, accessible table layout with enhanced keyboard navigation capabilities. As part of this, the handleKeydown method is responsible for managing keyboard navigation between table cells, handling focus, and managing the arrow, tab, and other keys. The current implementation of the handleKeydown method has grown more complex over time, making it harder to maintain and reason about. The goal of this issue is to refactor the method into a more readable and maintainable format, while preserving the functionality and accessibility of the keyboard navigation.

The Value Add

  • Improving overall code quality in the KTable component.
  • Ensuring that future modifications to the keyboard navigation behavior can be made more easily.
  • Improving overall code quality in the KTable component.

Possible Tradeoffs

Potential performance considerations: although the goal is to refactor for readability, care should be taken to avoid performance regressions, especially when handling key events frequently during table navigation.

Guidance

Please refer to this discussion for a better understanding of the implementation. In Summary,

  • Focus on breaking down the handleKeydown logic into smaller, modular methods that perform specific actions, such as handling different key events (i.e., arrow keys, tab, enter).
  • Avoid introducing unnecessary complexity; ensure the refactor simplifies the code.
  • Ensure that the refactor maintains the existing functionality, including:
    • Navigating between cells using arrow keys.
    • Handling focus management across rows and columns.
    • Supporting sticky headers and columns as described in the component behavior.
  • Include unit tests for the refactored code, especially around the key navigation and focus management aspects.

Acceptance Criteria

  • [ ] No regressions in existing keyboard navigation functionality.
  • [ ] Code is significantly more readable and easier to understand.
  • [ ] Unit tests are added or updated to cover the refactored method (if any)
  • [ ] No performance regressions due to the refactor.

BabyElias avatar Oct 04 '24 10:10 BabyElias

Hi @MisRob , May I look into this one?

shivam-daksh avatar Oct 07 '24 00:10 shivam-daksh

Hi @shivam-daksh, thank you, I will assign you. Please have a look at a linked discussion to get a sense of direction and pay attention to acceptance criteria. KTable has many keyboard and screen reader features - I would recommend to spend some time understanding the current implementation in detail.

MisRob avatar Oct 07 '24 12:10 MisRob

@MisRob Sure I will. 😊

shivam-daksh avatar Oct 07 '24 12:10 shivam-daksh

Lovely, thank you @shivam-daksh

MisRob avatar Oct 07 '24 12:10 MisRob

@shivam-daksh as soon as you open a PR, would you please mention @BabyElias there as well? She's the author of the table and interested in joining the reviews. Thank you!

MisRob avatar Oct 15 '24 14:10 MisRob

Hi @shivam-daksh, I wanted to mention that we will be closed from December 23 to January 5. It seems we will get to this QA rather next year, so hopefully then we can make progress toward merging all this wonderful work. Thanks!

MisRob avatar Dec 17 '24 17:12 MisRob