You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ref handling in ContentEditableText is incorrect: elementRef is stored as an HTMLElement but later accessed as elementRef.current, which will always be undefined. This prevents blur logic (Enter/Escape) from working. Consider using useRef and passing the ref object directly.
const[elementRef,setElementRef]=useState<HTMLElement|null>(null);useEffect(()=>{setCurrentValue(value);},[value]);// Set initial content and update when not editing to preserve cursor positionuseEffect(()=>{if(elementRef){if(!isEditing){constdisplayValue=currentValue||placeholder;if(elementRef.textContent!==displayValue){elementRef.textContent=displayValue;}}}},[elementRef,currentValue,placeholder,isEditing]);// Set initial content on mountuseEffect(()=>{if(elementRef&&!isEditing){constdisplayValue=currentValue||placeholder;elementRef.textContent=displayValue;}},[elementRef]);consthandleFocus=useCallback(()=>{setIsEditing(true);},[]);consthandleBlur=useCallback(()=>{setIsEditing(false);if(currentValue!==value){onSave(currentValue);}},[currentValue,value,onSave]);consthandleInput=useCallback((e: React.FormEvent<HTMLElement>)=>{constnewValue=e.currentTarget.textContent||'';setCurrentValue(newValue);},[]);consthandleKeyDown=useCallback((e: React.KeyboardEvent)=>{if(e.key==='Enter'&&!e.shiftKey){e.preventDefault();elementRef.current?.blur();}if(e.key==='Escape'){setCurrentValue(value);elementRef.current?.blur();}},[value],);
There are two consecutive useEffect hooks (lines 31–40 and 43–48) performing the same initial content setup. Refactor or merge them to avoid redundancy and reduce maintenance overhead.
useEffect(()=>{if(elementRef){if(!isEditing){constdisplayValue=currentValue||placeholder;if(elementRef.textContent!==displayValue){elementRef.textContent=displayValue;}}}},[elementRef,currentValue,placeholder,isEditing]);// Set initial content on mountuseEffect(()=>{if(elementRef&&!isEditing){constdisplayValue=currentValue||placeholder;elementRef.textContent=displayValue;}},[elementRef]);
The contentEditable element lacks ARIA roles and labels, which may hinder screen reader users. Consider adding role="textbox" and an appropriate aria-label or aria-labelledby.
Why: Using state for elementRef and casting it is incorrect and never sets the DOM node; switching to useRef ensures elementRef.current correctly references the element.
High
Remove clearing children prop
Remove the children={undefined} prop so React does not clear the contentEditable DOM children on each render.
-children={undefined}+// remove the children prop entirely
Suggestion importance[1-10]: 6
__
Why: The children={undefined} prop is unnecessary and can cause React to clear the element’s content; removing it preserves the manually managed textContent.
Low
General
Use event target to blur
Use e.currentTarget.blur() to blur the element instead of relying on elementRef, avoiding inconsistent ref access.
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
- elementRef.current?.blur();+ (e.currentTarget as HTMLElement).blur();
}
Suggestion importance[1-10]: 4
__
Why: Blurring via e.currentTarget is more reliable than using the ref and simplifies the handler, though it only addresses the Enter case.
Low
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement, Tests, Documentation
Description
Add unified NodePanel component layout
Implement inline and multiline editable fields
Integrate nodePanel into dropdown and toolbar
Add basic render test for NodePanel
Changes walkthrough 📝
3 files
Add ContentEditableText inline editing componentAdd ContentEditableTextarea multiline editing componentCreate unified NodePanel component layout1 files
Add basic NodePanel render test4 files
Add Node Panel item to layout dropdownInclude NodePanel in toolbar layout buttonsIntegrate nodePanel in layout controllerIntegrate nodePanel in default UI layout1 files
Document unified Node Panel components