Custom renderers prevent automatic renaming abort on outside click
combdn opened this issue · 3 comments
Describe the bug
When using custom renderers, renaming seems to be automatically aborted only when I click on the other three items. If I click outside of the tree, the renaming input loses focus, but the item is still stuck in the renaming state.
To Reproduce
‘Blueprint JS Renderers’ storybook has the same issue:
CleanShot.2024-04-25.at.13.34.16.mp4
Expected behaviour
‘Single Tree’ storybook with the default renderers behaves correctly:
CleanShot.2024-04-25.at.13.47.52.mp4
Additional context
I’m using Blueprint JS renderers as a starting point, so it might be the same issue as in the storybook.
Hey @combdn, thanks for the report! The reason, why the blur-based rename aborting didn't work with the blueprintjs renderers, was because the rename-submit button required registration through a ref, so essentially this was the fix. If this ref is missing, the library can't figure out if the input-blur happened because the user clicked on the submit button, in which case we of course don't want to abort renaming.
The current default is of course not a great one, so as of 2.4.3 I've changed it to still properly abort renaming if the submit button ref was not passed (e.g. if no submit button exists). But if you do have a rename-submit button, you probably also want to add the ref to the button.
Thank you very much for fixing it!
BTW, I’m finding Blueprint JS renderers a great reference. I think they deserve more emphasis in the docs as such.
Happy to hear! Good point, yeah they would probably make sense to mention in relation to how to write renderers, I'll expand that docs section.