-
Notifications
You must be signed in to change notification settings - Fork 336
Add open_in_new_tab parameter to me.navigate #1325
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
Conversation
Co-authored-by: richard-to <[email protected]>
Co-authored-by: richard-to <[email protected]>
Co-authored-by: richard-to <[email protected]>
Co-authored-by: richard-to <[email protected]>
|
|
||
| if (openInNewTab) { | ||
| // For relative URLs, resolve to absolute URL before opening in new tab | ||
| const absoluteUrl = url.startsWith('http://') || url.startsWith('https://') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's potentially other url formats that are absolute. Is there a more robust way to distinguish this? This is ok to ignore since we use similar pattern for the other case.
…oto comment Co-authored-by: richard-to <[email protected]>
| me.text("Click the buttons below to test navigation in new tabs:") | ||
|
|
||
| with me.box(style=me.Style(margin=me.Margin.all(15))): | ||
| me.button("Open about page in new tab", on_click=navigate_to_about_new_tab) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I try to test this, a new tab opens to the right page. However the current page also changes to the same page as the new tab.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 85d8365 - the issue was that query_params().clear() was being called even when opening in a new tab, which caused the current page to update. Now query params are only cleared when navigating in the same tab (open_in_new_tab=False).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it out and it still shows the same behavior.
Co-authored-by: richard-to <[email protected]>
Co-authored-by: richard-to <[email protected]>
Fixed critical bug where opening an internal app page in a new tab would also navigate the current page to the same URL. Root cause: The server was processing NavigateCommand for relative URLs by changing the path variable and rendering the new page, then sending that UI back to the current tab, causing unwanted navigation. Changes: - Server (server.py): Skip navigation logic when open_in_new_tab is true - Breaks out of navigate command processing to avoid path changes - Renders current page unchanged while frontend opens new tab - Frontend (shell.ts): Added explicit return after window.open() - Prevents any potential fall-through or async issues The fix ensures that when open_in_new_tab=True: 1. Frontend opens new tab with window.open() and returns immediately 2. Server skips all path changes and renders current page as-is 3. Current page remains unchanged while new tab loads independently Fixes the issue reported in PR #1325
|
Closing this pull request in favor of #1330 |
Plan: Add
open_in_new_tabparameter tome.navigateopen_in_new_tabfield to NavigateCommandnavigate()function to acceptopen_in_new_tabparameternavigate()method to passopen_in_new_tabto protoopen_in_new_tabflag with proper URL resolutionmesop/examples/testing/directory/navigate_new_tabto/testing/navigate_new_tab/aboutto/testing/navigate_new_tab_target(more descriptive)google.comtoexample.comLatest Changes:
Improved comment clarity in the
navigate()function to be more concise while still explaining both the conditional logic and the reason for clearing query params.Original prompt
open_in_new_tabparameter to me.navigate #1287💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.