-
-
Notifications
You must be signed in to change notification settings - Fork 105
Add sheet query parameter to preselect schematic sheet #153
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
base: main
Are you sure you want to change the base?
Changes from all commits
ccf4283
685a3db
3a72dd4
503f52b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,7 +129,32 @@ class KiCanvasShellElement extends KCUIElement { | |
|
|
||
| try { | ||
| await this.project.load(vfs); | ||
| this.project.set_active_page(this.project.first_page); | ||
| // Determine which page to activate based on URL query parameter "sheet" | ||
| const url_params = new URLSearchParams(window.location.search); | ||
| const sheet_param = url_params.get("sheet"); | ||
| let target_page = this.project.first_page; | ||
| if (sheet_param) { | ||
| // Try to find a matching page | ||
| for (const page of this.project.pages()) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like this logic would be useful to move into
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea, but I don't know TS well enough to take it on. Sorry.
|
||
| if (page.page === sheet_param) { | ||
| target_page = page; | ||
| break; | ||
| } | ||
| if ( | ||
| page.name | ||
| ?.toLowerCase() | ||
| .includes(sheet_param.toLowerCase()) | ||
| ) { | ||
| target_page = page; | ||
| break; | ||
| } | ||
| if (page.filename === sheet_param) { | ||
| target_page = page; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| this.project.set_active_page(target_page); | ||
| this.loaded = true; | ||
| } catch (e) { | ||
| console.error(e); | ||
|
|
||
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'm not totally sure what the purpose of this attribute is. I tried removing it, and it seems to work just fine. I'd really appreciate it if you could explain it to me.
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.
Did you see my response to this? I wrote one, but perhaps I forgot to save it.
If you click on a schematic name in the list on the right, it is visually highlighted. That should also happen if we select a schematic with
sheet=. This code is necessary to highlight the sheet name if we usesheet=.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.
Alright, I haven't actually received that response yet. Anyway, this appears to be a component lifecycle issue. Perhaps we should think about opening another PR to fix it.
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 think there are indeed some imperfections here. Maybe something about
initialContentCallbackand it loaded but no event handler was registered. I would really recommend that we address the root cause of this issue. Well, anyway, it seems like this should be handled in another PR. After this issue is fixed, changes to fileproject-panel.tswill no longer be necessary. So we just accept its imperfections.