bito-code-review[bot] commented on code in PR #41100:
URL: https://github.com/apache/superset/pull/41100#discussion_r3418412371


##########
superset-frontend/src/explore/components/DataTableControl/FilterInput.test.tsx:
##########
@@ -34,3 +34,25 @@ test('Render a FilterInput', async () => {
 
   expect(onChangeHandler).toHaveBeenCalledTimes(4);
 });
+
+test('FilterInput does not steal focus when another input already has focus', 
() => {
+  const onChangeHandler = jest.fn();
+
+  // Create a plain DOM input, focus it before mounting FilterInput
+  const otherInput = document.createElement('input');
+  document.body.appendChild(otherInput);
+  otherInput.focus();
+  expect(document.activeElement).toBe(otherInput);
+
+  // Mount FilterInput with shouldFocus=true while the other input is focused
+  const { container } = render(
+    <FilterInput onChangeHandler={onChangeHandler} shouldFocus />,
+  );
+  const filterInput = container.querySelector('input') as HTMLInputElement;
+
+  // FilterInput should not have stolen focus from the already-focused input
+  expect(document.activeElement).not.toBe(filterInput);
+  expect(document.activeElement).toBe(otherInput);
+
+  document.body.removeChild(otherInput);

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing DOM cleanup on test failure</b></div>
   <div id="fix">
   
   Wrap the body of this test in a try/finally block (or use an afterEach) so 
that `document.body.removeChild(otherInput)` always runs, guaranteeing cleanup 
even if an assertion throws.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #36084b</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to