Skip to content

[FIX] Clear selected item state when switching projects - #3724

Merged
muli-cohen merged 2 commits into
mlrun:developmentfrom
amit-noy:ML-12831
Jul 13, 2026
Merged

[FIX] Clear selected item state when switching projects#3724
muli-cohen merged 2 commits into
mlrun:developmentfrom
amit-noy:ML-12831

Conversation

@amit-noy

@amit-noy amit-noy commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

📝 Description

When a user had an item's detail pane or version history open (on Jobs, Real-time pipelines, or Artifacts pages) and switched projects via the sidebar dropdown, the URL was naively replacing the project
name in place. This kept the artifact/item-specific segments in the URL, causing the next network request to still reference the previous project's item instead of loading a clean state for the new
project.
The fix strips artifact-specific path segments on project switch, so the user always lands on the section's main list of the new project with no leftover item context.


🛠️ Changes Made

  • ProjectDropdown.jsx: compute basePath before building project links - when the current path is deeper than depth 5 (i.e. an item is selected), strip back to /projects/:projectName/:section
  • ProjectDropdown.test.jsx: added EllipsisTooltip to the mock (was missing) and a new project switch navigation describe block with 7 test cases covering flat sections (depth 4), sub-tab main pages
    (depth 5), and selected-item pages (depth 6+)

✅ Checklist

  • I have given the PR a well-structured title describing the domain and the specific change that was made
  • I tested the changes in the browser (locally or via preview build)
  • I confirmed that existing tests pass
  • I added or updated unit / integration tests (if needed)
  • I checked that this change doesn’t introduce new console warnings or lint / formatting errors
  • I updated the relevant Jira ticket with the appropriate details and status

🔗 References


🚨 Potentially Breaking Changes

  • Yes
  • No

Includes DRC change

  • Yes
  • No

If yes -> requires bump NPM version


🔍 Additional Notes


📸 Screenshots / Demos


@amit-noy
amit-noy requested a review from muli-cohen July 12, 2026 10:43

const projectsList = useMemo(() => {
const parts = pathname.split('/')
const basePath = parts.length > 5 ? parts.slice(0, 4).join('/') : pathname

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What is 4? @amit-noy

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@muli-cohen The index at which to slice the path to keep only /projects/:projectName/:section which is the minimum depth of any section root in the app

@amit-noy

amit-noy commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator Author

@muli-cohen I Decided to replaced the slice approach because it was fragile.

If a new route depth is added, it breaks and the new approach builds the URL from scratch using named constants, so there's no magic number to maintain.

@muli-cohen
muli-cohen merged commit a9c44df into mlrun:development Jul 13, 2026
3 checks passed
muli-cohen pushed a commit that referenced this pull request Jul 13, 2026
…switch (#3725)

<!-- Title structure should start with a flag - either of these:
[FEAT] [FIX] [CHORE] [CI] [DOCS] [STYLE] [REFACTOR] [TEST] [BUILD] [PERF]
Followed by a clear representation - e.g:
[STYLE] Reformat components for linting compliance
[CI] Run tests on push for all branches
[FEAT] Add dark mode toggle in header
-->

## 📝 Description
<!-- A clear, concise summary of what this PR does. -->
<!-- Include context, motivation, or related issues (e.g., "Replaces Sass with CSS Modules"). -->

Two issues with the Nuclio module federation integration:

1. The breadcrumb did not show the function name when navigating into a Nuclio function - unlike datasets, models and other pages which correctly display the item name.
2. Switching projects while inside a Nuclio page did not reset the MF app - the previous function's state persisted in the new project context.

---

## 🛠️ Changes Made
<!-- List the main updates in this PR. -->
<!-- Example:
- Replaced Sass styles with CSS Modules
- Updated Button component props for accessibility
- Adjusted CI workflow to run on push for all branches
-->

- Derive the function name from the URL wildcard (`params['*']`) and pass it as `itemName` to `<Breadcrumbs />` — since Nuclio owns its own routing internally, the function name lives in the wildcard rather than a named route param
- Add `key={params.projectName}` to `<ErrorBoundary>` so the entire MF app subtree unmounts and remounts fresh when the project changes, resetting all internal Nuclio state
- Re-run the MF init effect on `params.projectName` change to reset `ready`/`error` state between projects

---

## ✅ Checklist

- [x] I have given the PR a well-structured title describing the domain and the specific change that was made
- [x] I tested the changes in the browser (locally or via preview build)
- [x] I confirmed that existing tests pass
- [ ] I added or updated unit / integration tests (if needed)
- [x] I checked that this change doesn’t introduce new console warnings or lint / formatting errors
- [x] I updated the relevant Jira ticket with the appropriate details and status


---

## 🔗 References
- Related ticket / issue: https://ecliptos.atlassian.net/browse/ORIS-3081
- Figma / design spec:
- Documentation:

---

## 🚨 Potentially Breaking Changes
- [ ] Yes
- [x] No

<!-- If yes, describe what breaks and how to migrate: -->
<!-- Example: Renamed prop `variant` → `type` in Button component -->

---

Includes DRC change
- [ ] Yes
- [x] No

If yes -> requires bump NPM version

---

## 🔍 Additional Notes
<!-- Optional: other context, performance considerations, or follow-up work -->
<!-- Example:
- TODO: Migrate remaining components away from Sass
- Known issue: minor layout flicker on mobile
-->

- Stale function name in URL on project switch is resolved by [#3724](#3724)

---

## 📸 Screenshots / Demos
<!-- Include before/after screenshots, GIFs, or video demos if the change affects UI. -->
<!-- You can drag and drop images here directly in the PR. -->

---
pini-sh-panda pushed a commit to pini-sh-panda/ui that referenced this pull request Jul 21, 2026
<!-- Title structure should start with a flag - either of these:
[FEAT] [FIX] [CHORE] [CI] [DOCS] [STYLE] [REFACTOR] [TEST] [BUILD] [PERF]
Followed by a clear representation - e.g:
[STYLE] Reformat components for linting compliance
[CI] Run tests on push for all branches
[FEAT] Add dark mode toggle in header
-->

## 📝 Description
<!-- A clear, concise summary of what this PR does. -->
<!-- Include context, motivation, or related issues (e.g., "Replaces Sass with CSS Modules"). -->

When a user had an item's detail pane or version history open (on Jobs, Real-time pipelines, or Artifacts pages) and switched projects via the sidebar dropdown, the URL was naively replacing the project 
name in place. This kept the artifact/item-specific segments in the URL, causing the next network request to still reference the previous project's item instead of loading a clean state for the new 
project.
The fix strips artifact-specific path segments on project switch, so the user always lands on the section's main list of the new project with no leftover item context.

---

## 🛠️ Changes Made
<!-- List the main updates in this PR. -->
<!-- Example:
- Replaced Sass styles with CSS Modules
- Updated Button component props for accessibility
- Adjusted CI workflow to run on push for all branches
-->

- `ProjectDropdown.jsx`: compute `basePath` before building project links - when the current path is deeper than depth 5 (i.e. an item is selected), strip back to `/projects/:projectName/:section`
- `ProjectDropdown.test.jsx`: added `EllipsisTooltip` to the mock (was missing) and a new `project switch navigation` describe block with 7 test cases covering flat sections (depth 4), sub-tab main pages
(depth 5), and selected-item pages (depth 6+)

---

## ✅ Checklist

- [x] I have given the PR a well-structured title describing the domain and the specific change that was made
- [x] I tested the changes in the browser (locally or via preview build)
- [x] I confirmed that existing tests pass
- [x] I added or updated unit / integration tests (if needed)
- [x] I checked that this change doesn’t introduce new console warnings or lint / formatting errors
- [x] I updated the relevant Jira ticket with the appropriate details and status


---

## 🔗 References
- Related ticket / issue: https://ecliptos.atlassian.net/browse/ML-12831
- Figma / design spec:
- Documentation:

---

## 🚨 Potentially Breaking Changes
- [ ] Yes
- [x] No

<!-- If yes, describe what breaks and how to migrate: -->
<!-- Example: Renamed prop `variant` → `type` in Button component -->

---

Includes DRC change
- [ ] Yes
- [x] No

If yes -> requires bump NPM version

---

## 🔍 Additional Notes
<!-- Optional: other context, performance considerations, or follow-up work -->
<!-- Example:
- TODO: Migrate remaining components away from Sass
- Known issue: minor layout flicker on mobile
-->

---

## 📸 Screenshots / Demos
<!-- Include before/after screenshots, GIFs, or video demos if the change affects UI. -->
<!-- You can drag and drop images here directly in the PR. -->

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

2 participants