Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
81fc1d3 to
b92b6cf
Compare
| return ( | ||
| <div | ||
| className="roamjs-tldraw-canvas-container relative z-10 h-full w-full overflow-hidden rounded-md border border-gray-300 bg-white" | ||
| data-page-uid={pageUid} |
There was a problem hiding this comment.
we need to add this back because i keep receiving error "No canvas page UID found"
There was a problem hiding this comment.
It seems there was come confusion on what the task was requesting. Unfortunately, the ticket should have been more clear, sorry.
If a user:
- selects dg tool
- toggle lock on
- creates a node
The dg tool/node should still be the current tool
If a user:
- selects dg tool
- toggles lock off (or leaves as default)
- creates a node
The current tool should be the select tool
This follows the same behavior as all other tldraw tools.
|
@mdroidian is this the same behavior we want for ENG-1383: Stay at the relation arrow menu after creating a relation? Based on the description in this ticket I understood that once the discourse relation tool is selected, it should stay locked there without doing any extra lock tool operation. In this latest push I had discourse node and relation tools to have the same behavior, but let me know if you interpret it differently. |
0211007 to
faa17a5
Compare
mdroidian
left a comment
There was a problem hiding this comment.
https://www.loom.com/share/07aab48252a744f4ad016e00e619e7e1
- cannot edit discourse nodes
- changing default tldraw lock behavior unnecessarily (unlocking on choosing select tool)
d0b007d to
7a44a8c
Compare
|
https://www.loom.com/share/878e7f7432b645ceb310c914ed200d93 Here's my updated test with the bugs you pointed out. I couldn't reproduce the unable to edit bug. Can you try again? |
| initialText: string; | ||
| imageUrl?: string; | ||
| }) => { | ||
| editor.updateInstanceState({ isToolLocked: false }); |
There was a problem hiding this comment.
🟡 Convert To action permanently destroys user's tool lock preference
In uiOverrides.tsx:160, editor.updateInstanceState({ isToolLocked: false }) unconditionally clears the global isToolLocked state as a side effect of using the "Convert To" context menu. This persists beyond the Convert To operation — after converting a text/image shape to a discourse node, the user's tool lock preference is permanently disabled for all future tool usage. The intent is to ensure the tool switches to "select" after conversion, but the implementation mutates global state rather than just calling editor.setCurrentTool("select") directly in the onSuccess callback at uiOverrides.tsx:198.
Prompt for agents
In apps/roam/src/components/canvas/uiOverrides.tsx, remove the line `editor.updateInstanceState({ isToolLocked: false });` at line 160 inside `openDialogAndCreateShape`. Then at line 198, replace `setCurrentToolToSelectIfUnlocked(editor);` with `editor.setCurrentTool("select");` since Convert To should always end on the select tool regardless of tool lock state, without clearing the user's global tool lock preference.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
@trangdoan982 Why are we changing the lock state here? Wthat problem is this solving?
| if (action === "create") { | ||
| restoreToolState(); | ||
| } else { | ||
| editor.setEditingShape(null); | ||
| dialogRenderedRef.current = false; | ||
| } |
There was a problem hiding this comment.
🟡 restoreToolState called twice on successful node creation, causing redundant tool re-entry
In DiscourseNodeUtil.tsx:587-588, when action === "create", restoreToolState() is called. Then ModifyNodeDialog.tsx:483 calls onClose() after await onSuccess(...) completes. The onClose handler at DiscourseNodeUtil.tsx:594-596 checks isCreating (which is true for new nodes) and calls restoreToolState() again. This causes editor.setCurrentTool(shape.type) to fire twice in succession when tool lock is active, which may trigger the tool's onEnter handler (setting cursor, etc.) redundantly. The onSuccess handler should not call restoreToolState() for create actions since onClose already handles it, or onClose should detect that restoration already happened.
| if (action === "create") { | |
| restoreToolState(); | |
| } else { | |
| editor.setEditingShape(null); | |
| dialogRenderedRef.current = false; | |
| } | |
| if (action === "create") { | |
| restoreToolState(); | |
| } else { | |
| editor.setEditingShape(null); | |
| dialogRenderedRef.current = false; | |
| } | |
Was this helpful? React with 👍 or 👎 to provide feedback.
mdroidian
left a comment
There was a problem hiding this comment.
There are some undesired changes that I am unclear why they are included in this PR.
Also, this devin comment is worth looking into: #851 (comment)
| ...position, | ||
| }, | ||
| ]); | ||
| setCurrentToolToSelectIfUnlocked(app); |
There was a problem hiding this comment.
Why are we changing the tool state here?
| }, | ||
| }, | ||
| ]); | ||
| setCurrentToolToSelectIfUnlocked(editor); |
There was a problem hiding this comment.
Why are we changing the tool here? This diverges from the regular tldraw pattern. eg
If tool = rectangle and I paste text that is not a dg shape, tool stays as rectangle.
If tool = rectangle and I paste text that is a dg shape, tool changes to select.
| initialText: string; | ||
| imageUrl?: string; | ||
| }) => { | ||
| editor.updateInstanceState({ isToolLocked: false }); |
There was a problem hiding this comment.
@trangdoan982 Why are we changing the lock state here? Wthat problem is this solving?
https://www.loom.com/share/07b5bafb3bb54450bbe9a40862f9cd4a