Skip to content

fix(react-keytips): handle KEYTIP_REMOVED/UPDATED in useKeytipsManager - #672

Open
Ray Winkelman (rwinkelman) wants to merge 4 commits into
microsoft:mainfrom
rwinkelman:fix/keytips-registry-remove-update-671
Open

Ray Winkelman (rwinkelman) wants to merge 4 commits into
microsoft:mainfrom
rwinkelman:fix/keytips-registry-remove-update-671

Conversation

@rwinkelman

Copy link
Copy Markdown

Summary

`useKeytipsManager` only subscribed to `KEYTIP_ADDED`, so the registry grew unbounded. Subscribe to `KEYTIP_UPDATED` and `KEYTIP_REMOVED` as `useKeytips` already does.

Fixes #671

Test plan

  • Register then unregister a keytip; `getKeytips()` no longer contains it
  • Update a keytip; registry reflects new props

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks like a focused fix that keeps the manager’s registry consistent with update and removal events.

Could we also add a useKeytipsManager regression test that registers a keytip, updates it and checks the new properties through getKeytips(), then unregisters it and checks that the entry is gone?

That would directly cover the stale-registry behavior this fixes.

Register a keytip, update it, and unregister it through useKeytipsManager so a stale registry cannot come back unnoticed.
@rwinkelman

Copy link
Copy Markdown
Author

Added useKeytipsManager coverage that registers a keytip, updates it, and checks the new content through getKeytips(), then unregisters it and checks the entry is gone.

yarn nx test react-keytips passed locally, including useKeytipsManager.test.ts.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me. The new test covers the registry update and removal behavior we discussed. Thanks for adding it!

@Hotell

Copy link
Copy Markdown
Contributor

Victor Genaev (@mainframev), the fix looks good, can you please double check and merge if all good ?

@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix(react-keytips): handle KEYTIP_REMOVED/UPDATED in useKeytipsManager",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
"comment": "fix(react-keytips): handle KEYTIP_REMOVED/UPDATED in useKeytipsManager",
"comment": "fix: handle KEYTIP_REMOVED/UPDATED in useKeytipsManager",

This branch has not been deployed

No deployments
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.

[Bug](react-keytips): useKeytipsManager registry grows unbounded - never handles KEYTIP_REMOVED or KEYTIP_UPDATED

5 participants