Feature request: support moving/reparenting widgets
This is a feature request for supporting moving widgets between DOM nodes, following up on a discord suggestion. Currently, calling widget.remove() followed by new_parent.mount(widget) works well for me and preserves the widget's state. It is however "not supported" and "not guaranteed to work in the future".
Context: I have been writing an outliner editor in textual, with every header containing a textarea and possibly subheaders. It has been a great dev experience, everything "just works" as expected and the app has come together smoothly. This is in part thanks to the simplicity of being able to rearrange headers in the outline -- eg move-left (promote one level), or move-right (demote one level) -- by simply unmounting them, and remounting them higher/lower in the hierarchy, preserving their state.
The ability to reparent/move/mount-unmount simplifies the logic greatly, since the moving header can contain any number of subheaders, each with fiddly state such as placement of the cursor in their textarea, whether they are saved or not, expanded or not, etc. If reparenting/moving widgets was not possible, all of that would have to be collected and recreated.
Similarly, one use of the outliner is to be in a dual-pane app, with one outline on the left, one on the right, and moving items from one outline to the other (both part of the same App DOM node). Think eg. triaging issues, assigning, prioritizing. Again, that is pleasantly trivial with the ability to reparent a widget, but becomes unpleasantly hairy without it.
(Reparenting might also be useful for drag-and-drop, automatic change of layout, etc)
While currently one needs to unmount and remount the widget, I assume the supported version of it would dispense with that and reparent the widget without unmounting it, as in widget.move_to(new_parent) or new_parent.adopt(widget).