You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "alexandrusoare (via GitHub)" <gi...@apache.org> on 2026/07/23 10:51:09 UTC

[PR] fix(explore): sync FilterInput value with parent filter state [superset]

alexandrusoare opened a new pull request, #42342:
URL: https://github.com/apache/superset/pull/42342

   ### SUMMARY
   
   The search input in the Explore Data tabs was uncontrolled — no `value` prop was passed. When the component re-rendered, the input cleared while the filter stayed applied. Makes `FilterInput` controlled with an internal buffer for responsive typing.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on code in PR #42342:
URL: https://github.com/apache/superset/pull/42342#discussion_r3655336388


##########
superset-frontend/src/explore/components/DataTableControl/FilterInput.test.tsx:
##########
@@ -53,6 +63,27 @@ test('FilterInput auto-focuses when a non-editable element (e.g. a tab) has focu
   }
 });
 
+test('FilterInput syncs displayed value from external value prop', () => {
+  const onChangeHandler = jest.fn();
+  const { rerender } = render(
+    <FilterInput onChangeHandler={onChangeHandler} value="hello" />,
+  );
+  const input = screen.getByRole('textbox') as HTMLInputElement;
+  expect(input.value).toBe('hello');
+
+  rerender(<FilterInput onChangeHandler={onChangeHandler} value="" />);
+  expect(input.value).toBe('');
+});
+
+test('FilterInput updates immediately on typing despite debounce', async () => {

Review Comment:
   `debounce` is mocked to pass through synchronously, so "despite debounce" isn't actually exercised — is the lag window (parent still on the old `value` while the user keeps typing) covered anywhere?



##########
superset-frontend/src/explore/components/DataTableControl/index.tsx:
##########
@@ -116,16 +123,24 @@ export const FilterInput = ({
   }, []);
 
   const theme = useTheme();
-  const debouncedChangeHandler = debounce(
-    onChangeHandler,
-    Constants.SLOW_DEBOUNCE,
+  const debouncedChangeHandler = useMemo(
+    () => debounce(onChangeHandler, Constants.SLOW_DEBOUNCE),
+    [onChangeHandler],
   );
+
+  useEffect(
+    () => () => debouncedChangeHandler.cancel(),

Review Comment:
   Does this `cancel()` drop the filter the user just typed when the pane remounts on a data refresh (the case the focus-effect comment above describes)?



##########
superset-frontend/src/explore/components/DataTableControl/FilterInput.test.tsx:
##########
@@ -19,10 +19,20 @@
 import { render, screen, userEvent } from 'spec/helpers/testing-library';
 import { FilterInput } from '.';
 
-jest.mock('lodash', () => ({
-  ...jest.requireActual('lodash'),
-  debounce: (fuc: Function) => fuc,
-}));
+jest.mock('lodash', () => {
+  const debounce = <T extends (...args: never[]) => unknown>(func: T) => {
+    const debounced = (...args: Parameters<T>) => func(...args);
+    debounced.cancel = jest.fn();
+    debounced.flush = jest.fn();

Review Comment:
   `flush` is never called by `FilterInput` — only `cancel` is, so this stub is dead.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #42342:
URL: https://github.com/apache/superset/pull/42342#issuecomment-5057572793

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | e8fd0acfe77d78d7ba457faceeea6c8dfcfd86ad |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a61f21e264e4c0008863d51 |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-42342--superset-docs-preview.netlify.app](https://deploy-preview-42342--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTQyMzQyLS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.Na0VeoteYSGRNmiIrA1OTdajgPlMIDGEYry1WwYH6Ak)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   |<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DctBCoAgEADAv-y5UMsk-kHP2HIlQVNWgyL6e97mMi9kTjFXWAA62BjP_WjGQDeelq-SkEk4f4uCMQcqfcWtdz5U4hYs5ZCe1bZi0Cg3KBqMJr1LKefZjHZS8P0) |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-42342--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #42342:
URL: https://github.com/apache/superset/pull/42342#issuecomment-5057669898

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/42342?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 65.18%. Comparing base ([`7e63b29`](https://app.codecov.io/gh/apache/superset/commit/7e63b29741a392bb3be92e77a883894f629579d9?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`e8fd0ac`](https://app.codecov.io/gh/apache/superset/commit/e8fd0acfe77d78d7ba457faceeea6c8dfcfd86ad?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 93 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@           Coverage Diff           @@
   ##           master   #42342   +/-   ##
   =======================================
     Coverage   65.18%   65.18%           
   =======================================
     Files        2768     2768           
     Lines      156099   156107    +8     
     Branches    35727    35728    +1     
   =======================================
   + Hits       101753   101761    +8     
     Misses      52382    52382           
     Partials     1964     1964           
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/42342/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [javascript](https://app.codecov.io/gh/apache/superset/pull/42342/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `70.82% <100.00%> (+<0.01%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/42342?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #42342:
URL: https://github.com/apache/superset/pull/42342#discussion_r3642569921


##########
superset-frontend/src/explore/components/DataTableControl/FilterInput.test.tsx:
##########
@@ -19,10 +19,20 @@
 import { render, screen, userEvent } from 'spec/helpers/testing-library';
 import { FilterInput } from '.';
 
-jest.mock('lodash', () => ({
-  ...jest.requireActual('lodash'),
-  debounce: (fuc: Function) => fuc,
-}));
+jest.mock('lodash', () => {
+  const debounce = <T extends (...args: never[]) => unknown>(func: T) => {
+    const debounced = (...args: Parameters<T>) => func(...args);
+    debounced.cancel = jest.fn();
+    debounced.flush = jest.fn();
+    return debounced;
+  };
+
+  return {
+    __esModule: true,
+    ...jest.requireActual('lodash'),
+    debounce,
+  };
+});

Review Comment:
   The component under test imports `debounce` from `lodash-es` (aliased in Jest config). Mocking `lodash` works only indirectly via module resolution and is brittle if the aliasing changes; mock `lodash-es` directly to ensure the mock always applies to the imported module.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "alexandrusoare (via GitHub)" <gi...@apache.org>.
alexandrusoare commented on code in PR #42342:
URL: https://github.com/apache/superset/pull/42342#discussion_r3672336046


##########
superset-frontend/src/explore/components/DataTableControl/FilterInput.test.tsx:
##########
@@ -53,6 +62,18 @@ test('FilterInput auto-focuses when a non-editable element (e.g. a tab) has focu
   }
 });
 
+test('FilterInput syncs displayed value from external value prop', () => {

Review Comment:
   good point, addressed it with a new test



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #42342:
URL: https://github.com/apache/superset/pull/42342#discussion_r3664260577


##########
superset-frontend/src/explore/components/DataTableControl/index.tsx:
##########
@@ -125,16 +132,24 @@ export const FilterInput = ({
   }, []);
 
   const theme = useTheme();
-  const debouncedChangeHandler = debounce(
-    onChangeHandler,
-    Constants.SLOW_DEBOUNCE,
+  const debouncedChangeHandler = useMemo(
+    () => debounce(onChangeHandler, Constants.SLOW_DEBOUNCE),
+    [onChangeHandler],
   );
+
+  useEffect(
+    () => () => debouncedChangeHandler.flush(),
+    [debouncedChangeHandler],
+  );

Review Comment:
   **Suggestion:** When `onChangeHandler` changes identity before the debounce delay expires, `useMemo` creates a new debounced function and the cleanup immediately flushes the old one. That invokes the previous callback with stale input during the parent render transition, potentially applying an obsolete filter before the new callback handles subsequent input. Keep a stable debounced wrapper around the latest callback, or explicitly transfer/cancel pending work instead of flushing a stale instance. [stale reference]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Parent callback changes can apply filters through obsolete state.
   - ⚠️ Explore table results may briefly reflect stale filter ownership.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Mount `FilterInput` through `TableControls` at
   `superset-frontend/src/explore/components/DataTablesPane/components/DataTableControls.tsx:97`,
   which passes `onInputChange` as `onChangeHandler`.
   
   2. Type into the input so the lodash-es debounce created at
   `DataTableControl/index.tsx:135-138` has pending work.
   
   3. Cause the parent to provide a new `onChangeHandler` identity before the debounce delay
   expires. The component's actual filtering callers currently memoize their handlers at
   `superset-frontend/src/explore/components/DataTablesPane/components/SamplesPane.tsx:132-135`
   and `SingleQueryResultPane.tsx:70-73`, but the `FilterInput` prop itself permits identity
   changes.
   
   4. React recomputes `debouncedChangeHandler` because of the dependency at `index.tsx:138`,
   then runs the prior effect cleanup at `index.tsx:140-143`; `.flush()` invokes the pending
   text through the old callback before subsequent input uses the new callback. A stable
   wrapper around the latest callback, or explicit cancellation/transfer of pending work,
   prevents this stale update.
   ```
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=cddad1c046034853900189bd3be15860&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=cddad1c046034853900189bd3be15860&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/explore/components/DataTableControl/index.tsx
   **Line:** 135:143
   **Comment:**
   	*Stale Reference: When `onChangeHandler` changes identity before the debounce delay expires, `useMemo` creates a new debounced function and the cleanup immediately flushes the old one. That invokes the previous callback with stale input during the parent render transition, potentially applying an obsolete filter before the new callback handles subsequent input. Keep a stable debounced wrapper around the latest callback, or explicitly transfer/cancel pending work instead of flushing a stale instance.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42342&comment_hash=4cf4d0f626af52c016a7020355007520591396a70f87a81f09f81b87056a52ab&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42342&comment_hash=4cf4d0f626af52c016a7020355007520591396a70f87a81f09f81b87056a52ab&reaction=dislike'>👎</a>



##########
superset-frontend/src/explore/components/DataTablesPane/components/DataTableControls.tsx:
##########
@@ -93,7 +94,11 @@ export const TableControls = ({
   const { canCopyClipboard: copyEnabled } = usePermissions();
   return (
     <TableControlsWrapper>
-      <FilterInput onChangeHandler={onInputChange} shouldFocus />
+      <FilterInput
+        onChangeHandler={onInputChange}
+        shouldFocus
+        value={filterText}
+      />

Review Comment:
   **Suggestion:** This newly added search input is also rendered by the error-state `TableControls` in `useResultsPane`, where `onInputChange` is `noOpInputChange` and no `filterText` is supplied. Typing in that visible control only changes the input's local buffer and cannot filter anything, so the error view presents a search field that silently does nothing. Either omit the filter control when filtering is unavailable or provide the corresponding filter state and handler for that path. [incomplete implementation]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Failed results views display a nonfunctional Search field.
   - ⚠️ Users receive no feedback that filtering is unavailable.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Trigger a results request failure handled by `useResultsPane` in
   `superset-frontend/src/explore/components/DataTablesPane/components/useResultsPane.tsx:135-151`.
   
   2. That error branch renders `TableControls` at `useResultsPane.tsx:138-147` with
   `onInputChange={noOpInputChange}` at line 144; `noOpInputChange` is defined as an empty
   callback at line 81.
   
   3. `TableControls` unconditionally renders the new `FilterInput` at
   `DataTableControls.tsx:97-101`, while the error branch does not provide `filterText`, so
   the component defaults its external value to an empty string.
   
   4. Type into the visible Search field. `FilterInput` updates only its local buffer at
   `DataTableControl/index.tsx:152-153`; its debounced callback invokes the no-op handler,
   and no filtered result grid exists in this error branch. The control should be omitted
   when filtering is unavailable or wired to meaningful state.
   ```
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=c7af32eff4104830a2cbcfff08868b5f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=c7af32eff4104830a2cbcfff08868b5f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/explore/components/DataTablesPane/components/DataTableControls.tsx
   **Line:** 97:101
   **Comment:**
   	*Incomplete Implementation: This newly added search input is also rendered by the error-state `TableControls` in `useResultsPane`, where `onInputChange` is `noOpInputChange` and no `filterText` is supplied. Typing in that visible control only changes the input's local buffer and cannot filter anything, so the error view presents a search field that silently does nothing. Either omit the filter control when filtering is unavailable or provide the corresponding filter state and handler for that path.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42342&comment_hash=1ee31168b22dbd3f9742c4f0ea9d567fb4e48fde5b17b10a2c70c4554f70a4d7&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42342&comment_hash=1ee31168b22dbd3f9742c4f0ea9d567fb4e48fde5b17b10a2c70c4554f70a4d7&reaction=dislike'>👎</a>



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #42342:
URL: https://github.com/apache/superset/pull/42342#discussion_r3664722240


##########
superset-frontend/src/explore/components/DataTableControl/index.tsx:
##########
@@ -100,9 +99,11 @@ export const CopyToClipboardButton = ({
 export const FilterInput = ({
   onChangeHandler,
   shouldFocus = false,
+  value = '',
 }: {
   onChangeHandler(filterText: string): void;
   shouldFocus?: boolean;
+  value?: string;
 }) => {

Review Comment:
   **Suggestion:** When callers omit `value`, this defaults the input to a controlled empty string. The error path in `useResultsPane` passes `noOpInputChange` and omits `filterText`, so typing invokes the no-op callback but the controlled input is immediately restored to `''`, making the search field unusable in that state. Either require callers to provide and update the value or preserve uncontrolled behavior when no value is supplied. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Error-state Explore search input cannot retain typed text.
   - ⚠️ Results error recovery UI exposes a nonfunctional controlled field.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Trigger a results request that returns an error; `useResultsPane` enters its
   `responseError` branch at
   `superset-frontend/src/explore/components/DataTablesPane/components/useResultsPane.tsx:190-203`.
   
   2. That branch renders `TableControls` with `onInputChange={noOpInputChange}` and no
   `filterText` at `useResultsPane.tsx:198-200`.
   
   3. `TableControls` passes the undefined prop to `FilterInput` as `value={filterText}` at
   `superset-frontend/src/explore/components/DataTablesPane/components/DataTableControls.tsx:97-101`;
   `FilterInput` applies its `value = ''` default at `DataTableControl/index.tsx:99-107` and
   binds it to the input at line 133.
   
   4. Type into the visible Search field. The change handler invokes the no-op callback at
   `useResultsPane.tsx:81`, while React continues supplying `value=''`, so the typed text
   immediately disappears and the error-state search field cannot retain input.
   ```
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=978c5818e5204229ac54c571c467ba8c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=978c5818e5204229ac54c571c467ba8c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/explore/components/DataTableControl/index.tsx
   **Line:** 99:107
   **Comment:**
   	*Api Mismatch: When callers omit `value`, this defaults the input to a controlled empty string. The error path in `useResultsPane` passes `noOpInputChange` and omits `filterText`, so typing invokes the no-op callback but the controlled input is immediately restored to `''`, making the search field unusable in that state. Either require callers to provide and update the value or preserve uncontrolled behavior when no value is supplied.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42342&comment_hash=e9f97fe19f4f3043fa57dfc861cb7655fdc5f489de88f56374a94bf70839d372&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42342&comment_hash=e9f97fe19f4f3043fa57dfc861cb7655fdc5f489de88f56374a94bf70839d372&reaction=dislike'>👎</a>



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42342:
URL: https://github.com/apache/superset/pull/42342#issuecomment-5057548009

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on code in PR #42342:
URL: https://github.com/apache/superset/pull/42342#discussion_r3665076122


##########
superset-frontend/src/explore/components/DataTablesPane/types.ts:
##########
@@ -76,6 +76,7 @@ export interface TableControlsProps extends DrillControlsProps {
   // {datasource.id}__{datasource.type}, eg: 1__table
   datasourceId?: string;
   onInputChange: (input: string) => void;
+  filterText?: string;

Review Comment:
   Optional `filterText` means a call site that forgets it silently falls back to the uncontrolled input this PR is fixing — make it required with `''`? `useResultsPane.tsx:192` already renders `<TableControls>` without it (inert there via `noOpInputChange`), so nothing type-checks the invariant for the next caller.



##########
superset-frontend/src/explore/components/DataTablesPane/components/SamplesPane.tsx:
##########
@@ -175,7 +176,8 @@ export const SamplesPane = ({
         columnTypes={coltypes}
         rowcount={rowcount}
         datasourceId={datasourceId}
-        onInputChange={handleInputChange}
+        onInputChange={setFilterText}
+        filterText={filterText}

Review Comment:
   Raw `filterText` re-renders the pane on every keystroke, and `TableControls`' `formattedData` memo busts each render since `formattedTimeColumns` is a fresh array — is re-mapping all rows per key acceptable, or should only the debounced value drive the pane? (with a time-formatted column and rowLimit 10k, `applyFormattingToTabularData` walks all rows plus a localStorage read in `getTimeColumns`; same pattern at `SingleQueryResultPane.tsx:85`)



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "alexandrusoare (via GitHub)" <gi...@apache.org>.
alexandrusoare commented on code in PR #42342:
URL: https://github.com/apache/superset/pull/42342#discussion_r3656464679


##########
superset-frontend/src/explore/components/DataTableControl/index.tsx:
##########
@@ -116,16 +123,24 @@ export const FilterInput = ({
   }, []);
 
   const theme = useTheme();
-  const debouncedChangeHandler = debounce(
-    onChangeHandler,
-    Constants.SLOW_DEBOUNCE,
+  const debouncedChangeHandler = useMemo(
+    () => debounce(onChangeHandler, Constants.SLOW_DEBOUNCE),
+    [onChangeHandler],
   );
+
+  useEffect(
+    () => () => debouncedChangeHandler.cancel(),

Review Comment:
   No — isLoading is what unmounts the component, and that's triggered by a data reload, not by the user typing. There's nothing pending in the debounce queue at that point.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #42342:
URL: https://github.com/apache/superset/pull/42342#discussion_r3656495192


##########
superset-frontend/src/explore/components/DataTableControl/FilterInput.test.tsx:
##########
@@ -19,10 +19,19 @@
 import { render, screen, userEvent } from 'spec/helpers/testing-library';
 import { FilterInput } from '.';
 
-jest.mock('lodash', () => ({
-  ...jest.requireActual('lodash'),
-  debounce: (fuc: Function) => fuc,
-}));
+jest.mock('lodash', () => {
+  const debounce = <T extends (...args: never[]) => unknown>(func: T) => {
+    const debounced = (...args: Parameters<T>) => func(...args);
+    debounced.cancel = jest.fn();
+    return debounced;
+  };
+
+  return {
+    __esModule: true,
+    ...jest.requireActual('lodash'),
+    debounce,
+  };
+});

Review Comment:
   **Suggestion:** The component imports `debounce` from `lodash-es`, but this test mocks `lodash`, which is a different module. Consequently the real debounce implementation remains active during these tests, leaving real pending timers and making the test behavior dependent on the debounce delay instead of the intended synchronous mock. [possible bug]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ FilterInput tests retain real debounce timers.
   - ⚠️ Callback assertions become timing-dependent.
   - ⚠️ Test cleanup may report pending asynchronous work.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Run the `FilterInput` tests in
   `superset-frontend/src/explore/components/DataTableControl/FilterInput.test.tsx`, which
   import `FilterInput` from
   `superset-frontend/src/explore/components/DataTableControl/index.tsx` at line 20.
   
   2. The test mock at `FilterInput.test.tsx:22-34` replaces the `lodash` module, while
   `FilterInput` imports `debounce` from `lodash-es` at `index.tsx:23`.
   
   3. Because Jest module names do not match, `index.tsx:126-129` creates a debounced handler
   using the real `lodash-es` implementation rather than the synchronous mock.
   
   4. Execute the typing test at `FilterInput.test.tsx:36-45`; `index.tsx:140-144` schedules
   the parent callback using the real `Constants.SLOW_DEBOUNCE` delay, leaving a real pending
   timer and making callback assertions timing-dependent. The mock should target `lodash-es`
   instead.
   ```
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=efee74c8f6fb4b7691da2b6e5431f2ac&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=efee74c8f6fb4b7691da2b6e5431f2ac&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/explore/components/DataTableControl/FilterInput.test.tsx
   **Line:** 22:34
   **Comment:**
   	*Possible Bug: The component imports `debounce` from `lodash-es`, but this test mocks `lodash`, which is a different module. Consequently the real debounce implementation remains active during these tests, leaving real pending timers and making the test behavior dependent on the debounce delay instead of the intended synchronous mock.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42342&comment_hash=8d9f776018c95034efd0a3456638b1398edf6a3050023ce061f1b4f38dbe0fd6&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42342&comment_hash=8d9f776018c95034efd0a3456638b1398edf6a3050023ce061f1b4f38dbe0fd6&reaction=dislike'>👎</a>



##########
superset-frontend/src/explore/components/DataTableControl/index.tsx:
##########
@@ -116,16 +123,24 @@ export const FilterInput = ({
   }, []);
 
   const theme = useTheme();
-  const debouncedChangeHandler = debounce(
-    onChangeHandler,
-    Constants.SLOW_DEBOUNCE,
+  const debouncedChangeHandler = useMemo(
+    () => debounce(onChangeHandler, Constants.SLOW_DEBOUNCE),
+    [onChangeHandler],
   );
+
+  useEffect(
+    () => () => debouncedChangeHandler.cancel(),
+    [debouncedChangeHandler],
+  );

Review Comment:
   **Suggestion:** The cleanup cancels the pending debounced update whenever `FilterInput` unmounts, so text entered within the debounce interval is discarded if the pane is remounted or the user changes tabs immediately after typing. Because the parent state is only updated by this debounced callback, the filter remains stale and the typed value is lost; flush the pending update before cleanup or update the parent state synchronously while retaining the debounced work for the expensive operation. [possible bug]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Explore Data filtering loses rapid user input.
   - ⚠️ Data table keyword state remains stale after remount.
   - ⚠️ Switching tabs can reset the displayed search term.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Open an Explore Data table that renders the `FilterInput` through the DataTable
   controls path in
   `superset-frontend/src/explore/components/DataTablesPane/components/DataTableControls.tsx`;
   the table filtering flow is consumed by `useKeywordFilter` in
   `superset-frontend/src/explore/components/DataTablesPane/components/useGridResultTable.tsx:107`.
   
   2. Type a new search term into the input. At
   `superset-frontend/src/explore/components/DataTableControl/index.tsx:140-144`, the
   displayed value is updated immediately, but the parent `onChangeHandler` is invoked only
   by the debounced handler created at lines 126-129.
   
   3. Before `Constants.SLOW_DEBOUNCE` expires, switch Explore Data tabs or otherwise trigger
   the pane remount that recreates `DataTableControls.tsx` and `FilterInput`.
   
   4. The cleanup at `index.tsx:131-134` calls `debouncedChangeHandler.cancel()`, so the
   pending parent update never runs. The parent filter state remains at its previous value,
   and the new controlled input instance receives that stale value through `externalValue` at
   lines 94-105, causing the user's recently typed filter to be discarded.
   ```
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=ecfba445c48f45ac8f54f39e3e4b75b2&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=ecfba445c48f45ac8f54f39e3e4b75b2&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/explore/components/DataTableControl/index.tsx
   **Line:** 131:134
   **Comment:**
   	*Possible Bug: The cleanup cancels the pending debounced update whenever `FilterInput` unmounts, so text entered within the debounce interval is discarded if the pane is remounted or the user changes tabs immediately after typing. Because the parent state is only updated by this debounced callback, the filter remains stale and the typed value is lost; flush the pending update before cleanup or update the parent state synchronously while retaining the debounced work for the expensive operation.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42342&comment_hash=f71ed51fe71e2addd85beb0427c796be6354edf824f7e8e94bdc4b43cd2165d2&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42342&comment_hash=f71ed51fe71e2addd85beb0427c796be6354edf824f7e8e94bdc4b43cd2165d2&reaction=dislike'>👎</a>



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #42342:
URL: https://github.com/apache/superset/pull/42342#issuecomment-5099451062

   @alexandrusoare msyavuz's thread on `index.tsx` around the debounce `cancel()` is still open, and I'm not sure the reply settles it. `filterText` lives in the parent regardless of `isLoading`, so if a reload flips `isLoading` while a keystroke is still sitting in the 500ms debounce window, `cancel()` on unmount drops it instead of flushing it through. Worth either swapping to `flush()` there or resolving the thread with more reasoning.
   
   Also flagging the Copilot/Codeant threads about mocking `lodash` vs the `lodash-es` import, they're open too. Probably a non-issue since `babel-plugin-lodash` rewrites `lodash-es` imports the same way (CI stays green either way), but worth resolving the bot comments so they don't linger.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42342:
URL: https://github.com/apache/superset/pull/42342#issuecomment-5106270589

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers a full AI review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on code in PR #42342:
URL: https://github.com/apache/superset/pull/42342#discussion_r3667113299


##########
superset-frontend/src/explore/components/DataTableControl/FilterInput.test.tsx:
##########
@@ -53,6 +62,18 @@ test('FilterInput auto-focuses when a non-editable element (e.g. a tab) has focu
   }
 });
 
+test('FilterInput syncs displayed value from external value prop', () => {

Review Comment:
   This asserts a re-render, but an uncontrolled input never cleared on re-render — the reported bug is the *remount* (SamplesPane returns `<Loading />`), which nothing here covers. Since `rerender` keeps the same instance, a regression that broke only the mount-time `useState(externalValue)` seed would still pass this suite.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42342:
URL: https://github.com/apache/superset/pull/42342#issuecomment-5065560766

   <!-- Bito Reply -->
   To mock `lodash-es` directly, update the `jest.mock` call in `FilterInput.test.tsx` to target the `lodash-es` module instead of `lodash`. This ensures the mock is correctly applied to the module being imported by the component.
   
   ```typescript
   jest.mock('lodash-es', () => {
     const debounce = <T extends (...args: never[]) => unknown>(func: T) => {
       const debounced = (...args: Parameters<T>) => func(...args);
       debounced.cancel = jest.fn();
       debounced.flush = jest.fn();
       return debounced;
     };
   
     return {
       __esModule: true,
       ...jest.requireActual('lodash-es'),
       debounce,
     };
   });
   ```
   
   **superset-frontend/src/explore/components/DataTableControl/FilterInput.test.tsx**
   ```
   jest.mock('lodash-es', () => {
     const debounce = <T extends (...args: never[]) => unknown>(func: T) => {
       const debounced = (...args: Parameters<T>) => func(...args);
       debounced.cancel = jest.fn();
       debounced.flush = jest.fn();
       return debounced;
     };
   
     return {
       __esModule: true,
       ...jest.requireActual('lodash-es'),
       debounce,
     };
   });
   ```


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42342:
URL: https://github.com/apache/superset/pull/42342#issuecomment-5092312362

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers a full AI review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "alexandrusoare (via GitHub)" <gi...@apache.org>.
alexandrusoare merged PR #42342:
URL: https://github.com/apache/superset/pull/42342


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on code in PR #42342:
URL: https://github.com/apache/superset/pull/42342#discussion_r3664353895


##########
superset-frontend/src/explore/components/DataTableControl/index.tsx:
##########
@@ -125,16 +132,24 @@ export const FilterInput = ({
   }, []);
 
   const theme = useTheme();
-  const debouncedChangeHandler = debounce(
-    onChangeHandler,
-    Constants.SLOW_DEBOUNCE,
+  const debouncedChangeHandler = useMemo(
+    () => debounce(onChangeHandler, Constants.SLOW_DEBOUNCE),
+    [onChangeHandler],
   );
+
+  useEffect(
+    () => () => debouncedChangeHandler.flush(),

Review Comment:
   This cleanup also runs whenever `onChangeHandler` identity changes, not just on unmount — intentional, or should the flush be ref-based with `[]` deps? `FilterInput` is exported, so a caller passing an inline handler would flush on every parent render and lose the debounce.



##########
superset-frontend/src/explore/components/DataTableControl/index.tsx:
##########
@@ -100,11 +100,18 @@ export const CopyToClipboardButton = ({
 export const FilterInput = ({
   onChangeHandler,
   shouldFocus = false,
+  value: externalValue = '',
 }: {
   onChangeHandler(filterText: string): void;
   shouldFocus?: boolean;
+  value?: string;
 }) => {
   const inputRef: RefObject<any> = useRef(null);
+  const [internalValue, setInternalValue] = useState(externalValue);
+
+  useEffect(() => {
+    setInternalValue(externalValue);

Review Comment:
   Can this drop a keystroke typed between the debounce firing and the parent's re-render landing, since it overwrites `internalValue` unconditionally? (type "ab", pause past the debounce, type "c" before the parent's render commits — `externalValue` goes `'' -> 'ab'` and resets the box to "ab")



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "alexandrusoare (via GitHub)" <gi...@apache.org>.
alexandrusoare commented on code in PR #42342:
URL: https://github.com/apache/superset/pull/42342#discussion_r3664692541


##########
superset-frontend/src/explore/components/DataTableControl/index.tsx:
##########
@@ -100,11 +100,18 @@ export const CopyToClipboardButton = ({
 export const FilterInput = ({
   onChangeHandler,
   shouldFocus = false,
+  value: externalValue = '',
 }: {
   onChangeHandler(filterText: string): void;
   shouldFocus?: boolean;
+  value?: string;
 }) => {
   const inputRef: RefObject<any> = useRef(null);
+  const [internalValue, setInternalValue] = useState(externalValue);
+
+  useEffect(() => {
+    setInternalValue(externalValue);

Review Comment:
   I have moved the debounce from the filterinput to the parent.



##########
superset-frontend/src/explore/components/DataTableControl/index.tsx:
##########
@@ -125,16 +132,24 @@ export const FilterInput = ({
   }, []);
 
   const theme = useTheme();
-  const debouncedChangeHandler = debounce(
-    onChangeHandler,
-    Constants.SLOW_DEBOUNCE,
+  const debouncedChangeHandler = useMemo(
+    () => debounce(onChangeHandler, Constants.SLOW_DEBOUNCE),
+    [onChangeHandler],
   );
+
+  useEffect(
+    () => () => debouncedChangeHandler.flush(),

Review Comment:
   I have moved the debounce from the filterinput to the parent 



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42342:
URL: https://github.com/apache/superset/pull/42342#issuecomment-5103981109

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers a full AI review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(explore): sync FilterInput value with parent filter state [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42342:
URL: https://github.com/apache/superset/pull/42342#issuecomment-5117523577

   **Bito Automatic Review Skipped – PR Already Merged**<br/><br/>Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.<br/>No action is needed if you didn't intend to review it. To get a review, you can type `/review` in a comment and save it


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org