Skip to content

Fix secondary menu not updating reactively when CRDs are created#17781

Open
cnotv wants to merge 1 commit into
rancher:masterfrom
cnotv:bugfix/16664-secondary-menu-reactivity
Open

Fix secondary menu not updating reactively when CRDs are created#17781
cnotv wants to merge 1 commit into
rancher:masterfrom
cnotv:bugfix/16664-secondary-menu-reactivity

Conversation

@cnotv
Copy link
Copy Markdown
Member

@cnotv cnotv commented May 22, 2026

Summary

Fixes #16664

Occurred changes and/or fixed issues

  • Added test for shell/components/__tests__/SideNav.test.ts
  • Added logic to make update the schema in shell/plugins/steve/subscribe.js

Technical notes summary

Areas or cases that should be tested

Areas which could experience regressions

Screenshot/Video

Kapture.2026-05-22.at.10.07.32.mp4

Checklist

  • The PR is linked to an issue and the linked issue has a Milestone, or no issue is needed
  • The PR has a Milestone
  • The PR template has been filled out
  • The PR has been self reviewed
  • The PR has a reviewer assigned
  • The PR has automated tests or clear instructions for manual tests and the linked issue has appropriate QA labels, or tests are not needed
  • The PR has reviewed with UX and tested in light and dark mode, or there are no UX changes
  • The PR has been reviewed in terms of Accessibility
  • The PR has considered, and if applicable tested with, the three Global Roles Admin, Standard User and User Base

@cnotv cnotv added this to the v2.15.0 milestone May 22, 2026
@cnotv cnotv self-assigned this May 22, 2026
@cnotv cnotv force-pushed the bugfix/16664-secondary-menu-reactivity branch from 0097a7d to 0dd1b59 Compare May 22, 2026 14:09
@cnotv cnotv force-pushed the bugfix/16664-secondary-menu-reactivity branch from 0dd1b59 to 94077c3 Compare May 22, 2026 14:53
@cnotv cnotv requested review from richard-cox and torchiaf May 22, 2026 14:54
* it means a CRD was added or removed. Re-build the nav so the new group
* shows up under "More Resources" without requiring a page refresh.
*/
countTypes(a, b) {
Copy link
Copy Markdown
Member

@richard-cox richard-cox May 22, 2026

Choose a reason for hiding this comment

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

we might need to reconsider this.

re-rendering the side nav on count change was something we used to do but hit large performance issues given counts change a lot, and in some scenarios there's 1000s of schemas (i.e. crossplane world).

in theory all new schema's should be picked up via the computed property allSchemasIds which has a watch that calls queueUpdate?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have no idea about this logic, as you are the master.
I made this bug go away, but if you have tips, I welcome them and shove them to the AI :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is the bug still reproducible when this part is removed? If not then it should be enough just to remove it. If so though it might be worth debugging the allSchemasIds part and see it can be fixed there

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's the whole point of the fix, and it does not work without it.
If you want to have time to experiment, I leave it to you to play around and keep the PR open till you feel is ok.

Copy link
Copy Markdown
Member

@torchiaf torchiaf left a comment

Choose a reason for hiding this comment

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

@cnotv @richard-cox I double-checked the allSchemasIds var and getGroups.

The new schemas are correctly added to allSchemasIds but the object count is still zero. I created a new CRD (test.com.item) and a CR (name: demo-item, type: test.com.item from the recording)

// DEBUG: Check if test.com.item is in the types and what's its count
if (Object.keys(types).includes('test.com.item')) {
  const testType = types['test.com.item'];
  const inStore = this.$store.getters.currentStore(testType.name);
  const count = this.$store.getters[`${ inStore }/count`](testType);
  console.log('[SideNav.getProductsGroups]   ✅ test.com.item FOUND in', mode, 'mode! Count:', count);
} else if (mode === 'used') {
  console.log('[SideNav.getProductsGroups]   ❌ test.com.item NOT found in USED mode');
}

const more = this.$store.getters['type-map/getTree'](productId, mode, types, clusterId, namespaceMode, currentType);

console.log('More', more);
apiVersion: test.com/v1
kind: Item
metadata:
  name: demo-item
EOF
Image
  • The new test.com.item is missing from children
  • After a page refresh, the count is finally 1

I think the problem is the store not receiving the count update for the new schema -> the getTree doesn't return the new entry.

The fact that the countTypes watcher works, means that there is a timing issue? Maybe when getGroups() is called the count is not updated yet...

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.

The secondary menu is not reactive when creating new Custom Resources

3 participants