Skip to content
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

Allow renaming tabs #1948

Closed
wants to merge 5 commits into from
Closed

Conversation

vdawg-git
Copy link

@vdawg-git vdawg-git commented Aug 31, 2024

Closes #1854

@vdawg-git vdawg-git marked this pull request as ready for review August 31, 2024 19:26
@vdawg-git
Copy link
Author

The renaming works, however some other part of the app sometimes throws an error after a document got renamed:

graphite_wasm.js:1255 error	
frontend/wasm/src/editor_api.rs:114While handling FrontendMessage ""UpdatePropertyPanelOptionsLayout"", 
JavaScript threw an error: JsValue(TypeError: Cannot use 'in' operator to search for 'columnWidgets' in undefinedTypeError: Cannot use 'in' operator to search for 'columnWidgets' in undefined    
at http://localhost:8080/src/wasm-communication/messages.ts:753:27    
at Array.reduce (<anonymous>)    
at http://localhost:8080/src/wasm-communication/messages.ts:752:42    
at Array.forEach (<anonymous>)    
at patchWidgetLayout (http://localhost:8080/src/wasm-communication/messages.ts:751:16)    
at http://localhost:8080/src/components/panels/Properties.svelte?t=1725132032461:286:4    
at callCallback (http://localhost:8080/src/wasm-communication/subscription-router.ts:25:9)    at Object.handleJsMessage (http://localhost:8080/src/wasm-communication/subscription-router.ts:33:5)    at http://localhost:8080/src/wasm-communication/editor.ts:18:19    
at http://localhost:8080/wasm/pkg/graphite_wasm.js:2388:37)

tmp: placeholder for renameAction

panel: newName first as arg

allow renaming document tabs
@vdawg-git
Copy link
Author

Sorry, in bed yesterday I noticed that the renaming should be cancel-able.

The PR notifications remembered me to implement that

Copy link
Member

@0HyperCube 0HyperCube left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution.; it works well so far.

I added some logging but I'm not able to reproduce your issue with the widget diffing in the properties. If you can reproduce it then please send the debug info.

@@ -182,6 +218,10 @@
align-items: center;
position: relative;

> button {
all: unset;
Copy link
Member

Choose a reason for hiding this comment

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

I think you accidentally disabled styling on the cross button with this.

@@ -87,7 +104,26 @@
}}
bind:this={tabElements[tabIndex]}
>
<TextLabel>{tabLabel.name}</TextLabel>
{#if isRenaming}
<input
Copy link
Member

Choose a reason for hiding this comment

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

The styling on this should probably match when renaming layers (e.g. no outline etc.).

https://github.com/vdawg-git/Graphite/blob/432385343e07eb01237ee3fd6d8c6d0e99810029/frontend/src/components/panels/Layers.svelte#L587

<TextLabel>{tabLabel.name}</TextLabel>
{#if isRenaming}
<input
type="text"
Copy link
Member

Choose a reason for hiding this comment

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

The default value for the input should probably be the current tab value rather than being empty.

@Keavon
Copy link
Member

Keavon commented Sep 2, 2024

It may be a few days before I can commit some changes that you can rely on to fix this so it behaves the same as layer renaming. I need to focus on other code priorities but I'll try to do that soon.

@TrueDoctor
Copy link
Member

@Keavon what is your status on this?

@Keavon
Copy link
Member

Keavon commented Sep 11, 2024

I haven't had time yet. It's probably a couple hours of work, but this feature isn't a priority since it adds no new functionality, so it hasn't been where I've put my focus in the past days. I'll try to avoid letting this rot for too long though.

@Keavon
Copy link
Member

Keavon commented Sep 11, 2024

Actually, on further thought, the hard part isn't what's done by this PR— it's the generalizing of the existing components. It requires unifying how the TextInput and TextLabel can behave like one another to support the exact renaming behavior seen currently, and as of yet exclusively, for layers in the Layers panel. Since, unfortunately, this PR doesn't take that approach, it isn't suitable for merging in its current state. But once I'm able to unify the behaviors of those two components and replace how it's used in the Layers panel, adding it to the document tab and sending that to the backend is about 10 minutes of work and would probably only use a few lines of code present in this PR. So it wouldn't actually make much sense to keep this PR around and reuse it when I have time for that, whenever that might be. The reality is that this is just a tricky frontend task that seems simple but isn't, so I don't suggest having it as a community-contributed task. Hopefully you got to learn a bit about the backend <-> frontend communication in this process, and sorry to waste your time with this @vdawg-git.

@Keavon Keavon closed this Sep 11, 2024
@vdawg-git
Copy link
Author

All good and thank you for the detailed explanation

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.

Allow renaming documents by clicking on the document tab
4 participants