Skip to content

Commit

Permalink
- resets the selected index
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-goldstein committed Apr 24, 2023
1 parent d4f9e8e commit cdf6f2e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const DataQualityDetailsComponent: React.FC<Props> = ({
patternIndexNames={patternIndexNames}
patternRollups={patternRollups}
selectedIndex={selectedIndex}
setSelectedIndex={setSelectedIndex}
updatePatternIndexNames={updatePatternIndexNames}
updatePatternRollup={updatePatternRollup}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const defaultProps: Props = {
patternRollups,
patterns,
selectedIndex: null,
setSelectedIndex: jest.fn(),
theme: DARK_THEME,
updatePatternIndexNames: jest.fn(),
updatePatternRollup: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface Props {
patternRollups: Record<string, PatternRollup>;
patterns: string[];
selectedIndex: SelectedIndex | null;
setSelectedIndex: (selectedIndex: SelectedIndex | null) => void;
theme: Theme;
updatePatternIndexNames: ({
indexNames,
Expand All @@ -73,6 +74,7 @@ const IndicesDetailsComponent: React.FC<Props> = ({
patternRollups,
patterns,
selectedIndex,
setSelectedIndex,
theme,
updatePatternIndexNames,
updatePatternRollup,
Expand All @@ -92,6 +94,7 @@ const IndicesDetailsComponent: React.FC<Props> = ({
pattern={pattern}
patternRollup={patternRollups[pattern]}
selectedIndex={selectedIndex}
setSelectedIndex={setSelectedIndex}
theme={theme}
updatePatternIndexNames={updatePatternIndexNames}
updatePatternRollup={updatePatternRollup}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const defaultProps = {
openCreateCaseFlyout: jest.fn(),
patternRollup: undefined,
selectedIndex: null,
setSelectedIndex: jest.fn(),
theme: DARK_THEME,
updatePatternIndexNames: jest.fn(),
updatePatternRollup: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ interface Props {
pattern: string;
patternRollup: PatternRollup | undefined;
selectedIndex: SelectedIndex | null;
setSelectedIndex: (selectedIndex: SelectedIndex | null) => void;
theme: Theme;
updatePatternIndexNames: ({
indexNames,
Expand All @@ -109,6 +110,7 @@ const PatternComponent: React.FC<Props> = ({
pattern,
patternRollup,
selectedIndex,
setSelectedIndex,
theme,
updatePatternIndexNames,
updatePatternRollup,
Expand Down Expand Up @@ -254,14 +256,22 @@ const PatternComponent: React.FC<Props> = ({
setPageIndex(selectedPageIndex);
}

// if the selected index is not expanded, expand it
if (itemIdToExpandedRowMap[selectedIndex.indexName] == null) {
toggleExpanded(selectedIndex.indexName);

containerRef.current?.scrollIntoView();
toggleExpanded(selectedIndex.indexName); // expand the selected index
}

containerRef.current?.scrollIntoView();
setSelectedIndex(null);
}
}, [itemIdToExpandedRowMap, items, pageSize, pattern, selectedIndex, toggleExpanded]);
}, [
itemIdToExpandedRowMap,
items,
pageSize,
pattern,
selectedIndex,
setSelectedIndex,
toggleExpanded,
]);

return (
<EuiPanel data-test-subj={`${pattern}PatternPanel`} hasBorder={false} hasShadow={false}>
Expand Down

0 comments on commit cdf6f2e

Please sign in to comment.