Copilot commented on code in PR #44959:
URL: https://github.com/apache/superset/pull/44959#discussion_r4186882420


##########
superset-frontend/src/explore/components/controls/ControlPopover/ControlPopover.test.tsx:
##########
@@ -209,6 +209,42 @@ test('Controlled mode', async () => {
   });
 });
 
+test('stays closed when a parent keeps open={false}', async () => {
+  const onOpenChange = jest.fn();
+  setupTest({
+    ...createProps(),
+    destroyOnHidden: true,
+    open: false,
+    onOpenChange,
+  });
+
+  expect(screen.queryByText('Control Popover Test')).not.toBeInTheDocument();
+  await userEvent.click(screen.getByTestId('control-popover'));
+  expect(onOpenChange).toHaveBeenCalledWith(true);
+  expect(screen.queryByText('Control Popover Test')).not.toBeInTheDocument();
+});
+
+test('does not close on Escape when a parent keeps open={true}', async () => {
+  const onOpenChange = jest.fn();
+  setupTest({
+    ...createProps(),
+    destroyOnHidden: true,
+    open: true,
+    onOpenChange,
+  });
+
+  expect(await screen.findByText('Control Popover Test')).toBeInTheDocument();
+
+  fireEvent.keyDown(screen.getByTestId('control-popover'), {
+    key: 'Escape',
+    code: 27,
+    charCode: 0,

Review Comment:
   The keyboard event shape is inconsistent with DOM `KeyboardEvent` (`code` 
should be a string like `'Escape'`, and `charCode` is not used for `keydown`). 
To make the test more realistic and less brittle, prefer 
`userEvent.keyboard('{Escape}')` or fire the event on `document` with `key: 
'Escape'`, `code: 'Escape'`, and (if needed) `keyCode: 27`.



##########
superset-frontend/src/explore/components/controls/ControlPopover/ControlPopover.tsx:
##########
@@ -148,20 +150,24 @@ const ControlPopover: FC<PopoverProps> = ({
       if (visible === undefined) {

Review Comment:
   `changeContainerScrollStatus` is currently called only when `visible` is 
`undefined`, and is invoked with `undefined` in that case. Since `onOpenChange` 
handlers typically receive a boolean, this branch is effectively dead and 
likely inverted. Consider changing the condition to `visible !== undefined` 
(and pass the boolean through), or remove this block entirely if the 
`useEffect` below is intended to be the single source of scroll-status updates.



-- 
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