Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Popup in compact interactive list #2149

Merged
merged 13 commits into from
May 1, 2024

Conversation

adoroshk
Copy link
Contributor

@adoroshk adoroshk commented Apr 26, 2024

Summary

Terra compact interactive list has to support terra-popup in its cell. As compact interactive list has its own key and focus event handlers, terra-popup content key and focus events propagation needs to be stopped in order for compact interactive list to preserve key navigation between cells.

This PR:

  1. Stops key and focus event propagation in terra-popup content.
  2. Updates terra-compact-interactive-list documentation and cell content example with popup inside of a cell.
  3. Updates terra-compact-interactive-list test example, adds new wdio tests and updates old ones.
  4. Updates jest snapshots for terra-popup.

Testing

This change was tested using:

  • WDIO
  • Jest
  • Visual testing (please attach a screenshot or recording)
  • Other (please describe below)
  • No tests are needed

Reviews

In addition to engineering reviews, this PR needs:

  • UX review
  • Accessibility review
  • Functional review

This PR resolves:

UXPLATFORM-10389

@adoroshk adoroshk self-assigned this Apr 26, 2024
@github-actions github-actions bot temporarily deployed to preview-pr-2149 April 26, 2024 22:04 Destroyed
@github-actions github-actions bot temporarily deployed to preview-pr-2149 April 29, 2024 13:48 Destroyed
@github-actions github-actions bot temporarily deployed to preview-pr-2149 April 29, 2024 16:33 Destroyed
@github-actions github-actions bot temporarily deployed to preview-pr-2149 April 29, 2024 20:51 Destroyed
@github-actions github-actions bot temporarily deployed to preview-pr-2149 April 29, 2024 21:13 Destroyed
@github-actions github-actions bot temporarily deployed to preview-pr-2149 April 29, 2024 21:29 Destroyed
@adoroshk adoroshk marked this pull request as ready for review April 29, 2024 21:34
@github-actions github-actions bot temporarily deployed to preview-pr-2149 April 30, 2024 12:49 Destroyed
@github-actions github-actions bot temporarily deployed to preview-pr-2149 April 30, 2024 13:27 Destroyed
@adoroshk adoroshk requested a review from a team April 30, 2024 13:48
@@ -237,6 +237,8 @@ class PopupContent extends React.Component {
onResize={this.handleOnResize}
refCallback={refCallback}
role={popupContentRole || null}
onKeyDown={event => event.stopPropagation()} // Added for Popup support in terra-compact-interactive-list. As focus trap doesn't stop key press event propagation to the CIL cell, it interferes with cell key press event handler.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should create a function will a useCallback hook for memoization to prevent unnecessary rerenders. Same comment for your new onFocus function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here: 0dc66ba

@@ -237,6 +237,8 @@ class PopupContent extends React.Component {
onResize={this.handleOnResize}
refCallback={refCallback}
role={popupContentRole || null}
onKeyDown={event => event.stopPropagation()} // Added for Popup support in terra-compact-interactive-list. As focus trap doesn't stop key press event propagation to the CIL cell, it interferes with cell key press event handler.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to stop the propagation for all keyboard actions or specific ones like Tab. I am not sure we want to blindly stop all key event propagation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The keys that might mess with the CIL are Tab and Arrow keys (Right/Left/Up/Down). However, as the key event propagation has been stopped on the popup content wrapper <div>, it only stops bubbling up to the CIL. The key event for all keys (including TAB) will still work inside the popup the same way they did before.

buttonRef.current.focus();
};

const handleOnChange = (e) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have a useCallback hook

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Callback added: cacc605

Comment on lines 52 to 53
const handleButtonClick = () => { setIsOpen(true); };
const handleRequestClose = () => { setIsOpen(false); };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should have a useCallback hook.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Callback added: cacc605

@github-actions github-actions bot temporarily deployed to preview-pr-2149 April 30, 2024 16:23 Destroyed
@github-actions github-actions bot temporarily deployed to preview-pr-2149 April 30, 2024 16:29 Destroyed
@github-actions github-actions bot temporarily deployed to preview-pr-2149 May 1, 2024 16:00 Destroyed
@adoroshk adoroshk merged commit bbc7c11 into main May 1, 2024
22 checks passed
@adoroshk adoroshk deleted the popup-in-compact-interactive-list-cell branch May 1, 2024 16:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants