Closed arusak closed 1 year ago
Hi! You need to add ref={props.submitButtonRef}
to the props of the submit button, then it should work. RCT checks if the input is blurred, i.e. the user clicks away from the input, and when that is the case, it canceles the renaming and hides the rename input. It uses a ref on the button to find out that the user is not actually cancelling the renaming, but clicking on the submit button. So without the ref, it thinks the user is just clicking away from the input, and unmounts the button and input before the submit logic can complete.
Hi, Lucas. Thank you, that worked. I still get a warning "Form submission canceled because the form is not connected" in console though it doesn't cause any problem for the app.
I suppose that has to do with that RCT runs the rename logic and unmounts the form before the browser can handle the form submission, but I think that shouldn't be an issue.
When I implement a custom
renderRenameInput
,onRenameItem
is not called.The code for
renderRenameInput
was taken (with small changes) from your BlueprintJS example.So with this code I select a tree item, press F2 and get my input. I change its value to some string and click 'ok' button. I expect the input to be gone and the string I entered to appear in the console. What I get: the input is gone (as expected), but nothing is displayed in the console.
When
renderRenameInput
is not set, I get a warning: "Form submission canceled because the form is not connected", thoughonRenameItem
is called and I see new value in the console. Maybe it has something to do with this bug.I use Chrome 111 on Windows 10.