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 VideoEffects Pane reseting focus when an item is selected #4618

Merged
merged 11 commits into from
May 21, 2024

Conversation

JamesBurnside
Copy link
Member

What

Instead of trying to change focus on mount, instead use an imperative handle to call focus() when openPane is called. We can't use focus on mount, because if the pane is already open its already mounted, but we still need to shift focus.

Why

Fix bug where whenever an item was selected, the focus would shift back to the none video effects item.

How Tested

Locally verified in both configuration page and call page that when the video effects pane is first opened the focus shifts to the first item, confirmed when the pane is already open and the effects button is clicked the focus shifts to the none item, and confirmed when an item is selected the focus does not shift back to the first item.

Copy link
Contributor

Copy link
Contributor

github-actions bot commented May 15, 2024

Calling bundle size is increased❗.

  • Current size: 4845727
  • Base size: 4845659
  • Diff size: 68

Copy link
Contributor

github-actions bot commented May 15, 2024

Chat bundle size is increased❗.

  • Current size: 2056535
  • Base size: 2056534
  • Diff size: 1

Copy link
Contributor

github-actions bot commented May 15, 2024

CallWithChat bundle size is increased❗.

  • Current size: 6170353
  • Base size: 6170285
  • Diff size: 68

Copy link
Contributor

Failed to pass the UI Test. If this PR is for UI change and the error is snapshot mismatch, please add "update_snapshots" label to the PR for updating the snapshot.

Copy link
Contributor

github-actions bot commented May 15, 2024

@azure/communication-react jest test coverage for stable.

Lines Statements Functions Branches
Base 25771 / 40004
64.42%
25771 / 40004
64.42%
710 / 1255
56.57%
2048 / 3242
63.17%
Current 25770 / 39998
64.42%
25770 / 39998
64.42%
710 / 1255
56.57%
2067 / 3251
63.58%
Diff -1 / -6
0%
-1 / -6
0%
0 / 0
0%
19 / 9
0.41%

Copy link
Contributor

github-actions bot commented May 15, 2024

@azure/communication-react jest test coverage for beta.

Lines Statements Functions Branches
Base 50263 / 80227
62.65%
50263 / 80227
62.65%
1028 / 2278
45.12%
2961 / 4834
61.25%
Current 50173 / 80230
62.53%
50173 / 80230
62.53%
1028 / 2278
45.12%
2919 / 4801
60.79%
Diff -90 / 3
-0.12%
-90 / 3
-0.12%
0 / 0
0%
-42 / -33
-0.46%

@JamesBurnside JamesBurnside added the update_snapshots Set this label to request automated update of UI snapshots label May 15, 2024
@github-actions github-actions bot removed the update_snapshots Set this label to request automated update of UI snapshots label May 15, 2024
Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm some of these looking a little flakey potentially

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah they're not! Every other test performs a click on a specific tile, hence why the focus rect does not show. In this test it does not perform a subsequent click and hence the focus rect shows.

Copy link
Contributor

Copy link
Contributor

*/
focusOnMount?: boolean;
componentRef?: React.RefObject<{
Copy link
Member

Choose a reason for hiding this comment

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

Interesting so we can set a action to take when the component reference is set?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's the concept of an imperative handle. You can do this today with regular html elements, e.g. document.getElementById("myTextField").focus();
(ref: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus).

In that example we get the handle by doing document.getElementById. In react world we can't do that, we have to do one render pass that renders the component and updates the ref, then once its been rendered (i.e. added to the DOM), we can define functions that can be executed on it. The action won't happen when the component reference is set, it happen anytime after its set when the owner of the handle calls the function

Copy link
Contributor

Copy link
Contributor

@JamesBurnside JamesBurnside enabled auto-merge (squash) May 21, 2024 22:56
Copy link
Contributor

@JamesBurnside JamesBurnside merged commit 23eec76 into main May 21, 2024
41 checks passed
@JamesBurnside JamesBurnside deleted the jaburnsi/fix-focus-videotilepicker branch May 21, 2024 23:08
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.

None yet

3 participants