Skip to content

Commit 3be94f5

Browse files
[8.19] [Observabililty] [Alert details] Fix active tab when opening new alert from Related alerts tab (elastic#224287) (elastic#224947)
# Backport This will backport the following commits from `main` to `8.19`: - [[Observabililty] [Alert details] Fix active tab when opening new alert from Related alerts tab (elastic#224287)](elastic#224287) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Bena Kansara","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-06-23T18:48:04Z","message":"[Observabililty] [Alert details] Fix active tab when opening new alert from Related alerts tab (elastic#224287)\n\nFixes tab selection issue when user opens alert details page from\n\"Related alerts\" tab. In this case, \"Overview\" tab should be selected by\ndefault. In other cases, tab Id passed from URL should be used otherwise\ndefault to \"Overview\".","sha":"4553774d5a3ed332be03eca6474208f157fd5b83","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:obs-ux-management","backport:version","v9.1.0","v8.19.0"],"title":"[Observabililty] [Alert details] Fix active tab when opening new alert from Related alerts tab","number":224287,"url":"https://github.com/elastic/kibana/pull/224287","mergeCommit":{"message":"[Observabililty] [Alert details] Fix active tab when opening new alert from Related alerts tab (elastic#224287)\n\nFixes tab selection issue when user opens alert details page from\n\"Related alerts\" tab. In this case, \"Overview\" tab should be selected by\ndefault. In other cases, tab Id passed from URL should be used otherwise\ndefault to \"Overview\".","sha":"4553774d5a3ed332be03eca6474208f157fd5b83"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/224287","number":224287,"mergeCommit":{"message":"[Observabililty] [Alert details] Fix active tab when opening new alert from Related alerts tab (elastic#224287)\n\nFixes tab selection issue when user opens alert details page from\n\"Related alerts\" tab. In this case, \"Overview\" tab should be selected by\ndefault. In other cases, tab Id passed from URL should be used otherwise\ndefault to \"Overview\".","sha":"4553774d5a3ed332be03eca6474208f157fd5b83"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Bena Kansara <[email protected]>
1 parent 4dcda7c commit 3be94f5

File tree

1 file changed

+5
-6
lines changed
  • x-pack/solutions/observability/plugins/observability/public/pages/alert_details

1 file changed

+5
-6
lines changed

x-pack/solutions/observability/plugins/observability/public/pages/alert_details/alert_details.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,7 @@ export function AlertDetails() {
129129
const [alertStatus, setAlertStatus] = useState<AlertStatus>();
130130
const { euiTheme } = useEuiTheme();
131131
const [sources, setSources] = useState<AlertDetailsSource[]>();
132-
const [activeTabId, setActiveTabId] = useState<TabId>(() => {
133-
const searchParams = new URLSearchParams(search);
134-
const urlTabId = searchParams.get(ALERT_DETAILS_TAB_URL_STORAGE_KEY);
135-
return urlTabId && isTabId(urlTabId) ? urlTabId : 'overview';
136-
});
132+
const [activeTabId, setActiveTabId] = useState<TabId>();
137133
const handleSetTabId = async (tabId: TabId) => {
138134
setActiveTabId(tabId);
139135

@@ -170,8 +166,11 @@ export function AlertDetails() {
170166
if (alertDetail) {
171167
setRuleTypeModel(ruleTypeRegistry.get(alertDetail?.formatted.fields[ALERT_RULE_TYPE_ID]!));
172168
setAlertStatus(alertDetail?.formatted?.fields[ALERT_STATUS] as AlertStatus);
169+
const searchParams = new URLSearchParams(search);
170+
const urlTabId = searchParams.get(ALERT_DETAILS_TAB_URL_STORAGE_KEY);
171+
setActiveTabId(urlTabId && isTabId(urlTabId) ? urlTabId : 'overview');
173172
}
174-
}, [alertDetail, ruleTypeRegistry]);
173+
}, [alertDetail, ruleTypeRegistry, search]);
175174

176175
useBreadcrumbs(
177176
[

0 commit comments

Comments
 (0)