When a container is un-selected the outer Focus widget sets canRequestFocus = false and skipTraversal = faslse on every descendant focus-node.
Because the TextField inside _SearchField owns its own persistent FocusNode, that flag stays false even after the container becomes selected again, so the Tab key can never land on that field any more – only on the button (which creates a brand-new internal focus-node each rebuild).
So the properties need to be updated once the container is selected again inside didUpdateWidget method and pass the isContainerSelected flag to the _SearchField widget from parent.
class _SearchFieldState extends State<_SearchField> {
final FocusNode _focusNode = FocusNode();
@override
void didUpdateWidget(final _SearchField oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.isSectionSelected != widget.isContainerSelected) {
_focusNode
..canRequestFocus = widget.isContainerSelected
..skipTraversal = !widget.isContainerSelected;
}
}
@override
void dispose() {
_focusNode.dispose();
super.dispose();
}
@override
Widget build(final BuildContext context) {
return TextField(
focusNode: _focusNode,
decoration: const InputDecoration(
hintText: 'Search',
),
);
}
}