Home / Function/ adjustSelectionAfterFilterChange() — react Function Reference

adjustSelectionAfterFilterChange() — react Function Reference

Architecture documentation for the adjustSelectionAfterFilterChange() function in useCommitFilteringAndNavigation.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  68892dee_ae3d_6c73_e4ba_819f15b5a33c["adjustSelectionAfterFilterChange()"]
  1d558132_0276_7e48_1a18_611bb9fef088["useCommitFilteringAndNavigation.js"]
  68892dee_ae3d_6c73_e4ba_819f15b5a33c -->|defined in| 1d558132_0276_7e48_1a18_611bb9fef088
  cb73e845_c62e_f2c7_edc2_9d5fbebe5580["setIsCommitFilterEnabled()"]
  cb73e845_c62e_f2c7_edc2_9d5fbebe5580 -->|calls| 68892dee_ae3d_6c73_e4ba_819f15b5a33c
  0d86cfc6_1b33_7482_7a0b_c6caa34710f0["setMinCommitDuration()"]
  0d86cfc6_1b33_7482_7a0b_c6caa34710f0 -->|calls| 68892dee_ae3d_6c73_e4ba_819f15b5a33c
  style 68892dee_ae3d_6c73_e4ba_819f15b5a33c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-shared/src/devtools/views/Profiler/useCommitFilteringAndNavigation.js lines 83–114

    (newFilteredIndices: Array<number>) => {
      const currentSelectedIndex = selectedCommitIndex;
      const selectedFilteredIndex = findFilteredIndex(
        currentSelectedIndex,
        newFilteredIndices,
      );

      if (newFilteredIndices.length === 0) {
        // No commits pass the filter - clear selection
        selectCommitIndex(null);
      } else if (currentSelectedIndex === null) {
        // No commit was selected - select first available
        selectCommitIndex(newFilteredIndices[0]);
      } else if (selectedFilteredIndex === null) {
        // Currently selected commit was filtered out - find closest commit before it
        let closestBefore = null;
        for (let i = newFilteredIndices.length - 1; i >= 0; i--) {
          if (newFilteredIndices[i] < currentSelectedIndex) {
            closestBefore = newFilteredIndices[i];
            break;
          }
        }
        // If no commit before it, use the first available
        selectCommitIndex(
          closestBefore !== null ? closestBefore : newFilteredIndices[0],
        );
      } else if (selectedFilteredIndex >= newFilteredIndices.length) {
        // Filtered position is out of bounds - clamp to last available
        selectCommitIndex(newFilteredIndices[newFilteredIndices.length - 1]);
      }
      // Otherwise, the current selection is still valid in the filtered list, keep it
    },

Domain

Subdomains

Frequently Asked Questions

What does adjustSelectionAfterFilterChange() do?
adjustSelectionAfterFilterChange() is a function in the react codebase, defined in packages/react-devtools-shared/src/devtools/views/Profiler/useCommitFilteringAndNavigation.js.
Where is adjustSelectionAfterFilterChange() defined?
adjustSelectionAfterFilterChange() is defined in packages/react-devtools-shared/src/devtools/views/Profiler/useCommitFilteringAndNavigation.js at line 83.
What calls adjustSelectionAfterFilterChange()?
adjustSelectionAfterFilterChange() is called by 2 function(s): setIsCommitFilterEnabled, setMinCommitDuration.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free