### Godot version

v4.1.rc1.official [1f9e540f1]

### System information

Windows 10

### Issue description

Attempting to reorder the children of a TabContainer results in an unintended ordering and incorrect undo states.

Also happens in v4.0.3.stable.official [5222a99f5].

https://github.com/godotengine/godot/assets/3820082/2c2458e3-88ad-46d9-8a04-f289a049984a



### Steps to reproduce

1. Add a new TabContainer
2. Add a few children to it
3. Drag and drop to erroneously reorder them
4. Attempt to undo the change

### Minimal reproduction project

N/A
bool was_empty = false;
			if (!node_clipboard.is_empty()) {
				_clear_clipboard();
			} else {
				was_empty = true;
			}
			clipboard_source_scene = EditorNode::get_singleton()->get_edited_scene()->get_scene_file_path();
			selection.sort_custom<Node::Comparator>();
			for (Node *node : selection) {
				HashMap<const Node *, Node *> duplimap;
				Node *dup = node->duplicate_from_editor(duplimap);
				ERR_CONTINUE(!dup);
				
				List<Node *> owned;
				node->get_owned_by(node->get_owner(), &owned);
				for (Node *F : owned) {
					if (!duplimap.has(F) || F == node) {
						continue;
					}
					Node *d = duplimap[F];
					
					
					d->set_owner(dup);
				}
				node_clipboard.push_back(dup);
			}
			if (p_tool == TOOL_CUT) {
				_delete_confirm(true);
			}
			if (was_empty) {