Skip to content

Commit 481c983

Browse files
committed
fix: lint fix
1 parent 0411b7a commit 481c983

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

src/OptionList.tsx

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,6 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
102102
// eslint-disable-next-line react-hooks/exhaustive-deps
103103
}, [open]);
104104

105-
// =========================== Search Effect ===========================
106-
React.useEffect(() => {
107-
if (searchValue) {
108-
setSearchExpandedKeys(getAllKeys(treeData, fieldNames));
109-
110-
const firstMatchNode = getFirstMatchNode(memoTreeData);
111-
if (firstMatchNode) {
112-
setActiveKey(firstMatchNode[fieldNames.value]);
113-
} else {
114-
setActiveKey(null);
115-
}
116-
}
117-
// eslint-disable-next-line react-hooks/exhaustive-deps
118-
}, [searchValue]);
119-
120105
// ========================== Events ==========================
121106
const onListMouseDown: React.MouseEventHandler<HTMLDivElement> = event => {
122107
event.preventDefault();
@@ -138,21 +123,6 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
138123
}
139124
};
140125

141-
const getFirstMatchNode = (nodes: EventDataNode<any>): EventDataNode<any> | null => {
142-
for (const node of nodes) {
143-
if (filterTreeNode(node) && !node.disabled) {
144-
return node;
145-
}
146-
if (node[fieldNames.children]) {
147-
const matchInChildren = getFirstMatchNode(node[fieldNames.children]);
148-
if (matchInChildren) {
149-
return matchInChildren;
150-
}
151-
}
152-
}
153-
return null;
154-
};
155-
156126
// ========================== Search ==========================
157127
const lowerSearchValue = String(searchValue).toLowerCase();
158128
const filterTreeNode = (treeNode: EventDataNode<any>) => {
@@ -182,6 +152,36 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
182152
}
183153
};
184154

155+
const getFirstMatchNode = (nodes: EventDataNode<any>): EventDataNode<any> | null => {
156+
for (const node of nodes) {
157+
if (filterTreeNode(node) && !node.disabled) {
158+
return node;
159+
}
160+
if (node[fieldNames.children]) {
161+
const matchInChildren = getFirstMatchNode(node[fieldNames.children]);
162+
if (matchInChildren) {
163+
return matchInChildren;
164+
}
165+
}
166+
}
167+
return null;
168+
};
169+
170+
// =========================== Search Effect ===========================
171+
React.useEffect(() => {
172+
if (searchValue) {
173+
setSearchExpandedKeys(getAllKeys(treeData, fieldNames));
174+
175+
const firstMatchNode = getFirstMatchNode(memoTreeData);
176+
if (firstMatchNode) {
177+
setActiveKey(firstMatchNode[fieldNames.value]);
178+
} else {
179+
setActiveKey(null);
180+
}
181+
}
182+
// eslint-disable-next-line react-hooks/exhaustive-deps
183+
}, [searchValue]);
184+
185185
// ========================= Keyboard =========================
186186
React.useImperativeHandle(ref, () => ({
187187
scrollTo: treeRef.current?.scrollTo,

0 commit comments

Comments
 (0)