[Solved]2021.3 UIToolkit TextField in ListView editingState error

GIF

The focus state of the TextField in the ListView item reappears after scrolling out of the view and back in. When editing the selected TextField and selecting another item to cancel the edit state, if the item is scrolled out of view and then back into view, the TextField’s edit state reappears, while the selection state of the other item still exists. This results in an editing TextField and a selected item being different object. how to resolve this

My code

        public void CreateGUI()
        {
            VisualElement root = rootVisualElement;
            m_VisualTree.CloneTree(root);

            m_SearchField = root.Q<ToolbarSearchField>("SearchField");
            m_ListView = root.Q<ListView>("ListView");

            InitListView();
        }

        private void InitListView()
        {
            m_ListView.itemsSource = m_Tags;
            m_ListView.showAddRemoveFooter = true;
            m_ListView.selectionType = SelectionType.Single;
            m_ListView.makeItem = ListViewMakeItem;
            m_ListView.bindItem = ListViewBindItem;
        }

        private VisualElement ListViewMakeItem()
        {
                return m_TagItem.CloneTree();
        }

        private void ListViewBindItem(VisualElement element, int i)
        {
                var item = m_Tags[i] as MapTag;
                var id = element.Q<Label>("id");
                var text = element.Q<TextField>("text");
                id.text = item.id.ToString();
                text.value = item.name;
                element.style.height = 30;
                element.userData = m_Tags[i];
                return;
        }

Gif2

Update: using UI Tool Kit Event Debugger, find out Text Field Focus and Select All triggered by List View
ExecuteDefaultAction when item scroll back

so I clear the FocusedItem with Reflection when I blur the Text Field, and now perform as I expected

            var dispatchModeType = typeof(FocusController).Assembly.GetType("UnityEngine.UIElements.DispatchMode");
            MethodInfo switchFocusMethod = typeof(FocusController).GetMethod(
                "SwitchFocus",
                BindingFlags.NonPublic | BindingFlags.Instance,
                null,
                new[] { typeof(Focusable), typeof(FocusChangeDirection), typeof(bool), dispatchModeType },
                null
            );
            if (switchFocusMethod != null)
            {
                var defaultMode = Enum.Parse(dispatchModeType, "Default");
                switchFocusMethod.Invoke(m_ListView.focusController, new object[] { null, FocusChangeDirection.unspecified, false, defaultMode });
            }

don’t know is there any better way to resolve this problem?

Final Update: set the List view item is Focusable Resolve this problem
selecting another item will be right.
<ui:VisualElement name="TagItem" focusable="true" >