From 3552801ca5338722dab638516eec6df0603f34eb Mon Sep 17 00:00:00 2001 From: Abhishek S Lal Date: Mon, 22 Dec 2025 13:40:51 +0530 Subject: [PATCH] fix: refactor default tab selection logic for correct tab persistance (#6473) --- .../components/RequestPane/HttpRequestPane/index.js | 10 +--------- packages/bruno-app/src/utils/collections/index.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js b/packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js index aaf7dcd1b..41a512781 100644 --- a/packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js +++ b/packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js @@ -1,4 +1,4 @@ -import React, { useEffect, useRef, useCallback, useMemo } from 'react'; +import React, { useRef, useCallback, useMemo } from 'react'; import classnames from 'classnames'; import { useSelector, useDispatch } from 'react-redux'; import { find, get } from 'lodash'; @@ -53,7 +53,6 @@ const HttpRequestPane = ({ item, collection }) => { const activeTabUid = useSelector((state) => state.tabs.activeTabUid); const rightContentRef = useRef(null); - const initialAutoSelectDone = useRef(false); const focusedTab = find(tabs, (t) => t.uid === activeTabUid); const requestPaneTab = focusedTab?.requestPaneTab; @@ -117,13 +116,6 @@ const HttpRequestPane = ({ item, collection }) => { return Component ? :
404 | Not found
; }, [requestPaneTab, item, collection]); - useEffect(() => { - if (!initialAutoSelectDone.current && activeCounts.params === 0 && body.mode !== 'none') { - selectTab('body'); - } - initialAutoSelectDone.current = true; - }, [activeCounts.params, body.mode, selectTab]); - if (!activeTabUid || !focusedTab?.uid || !requestPaneTab) { return
An error occurred!
; } diff --git a/packages/bruno-app/src/utils/collections/index.js b/packages/bruno-app/src/utils/collections/index.js index 6c04bd910..6eb2bd78d 100644 --- a/packages/bruno-app/src/utils/collections/index.js +++ b/packages/bruno-app/src/utils/collections/index.js @@ -1060,6 +1060,16 @@ export const hasExampleChanges = (_item, exampleUid) => { export const getDefaultRequestPaneTab = (item) => { if (item.type === 'http-request') { + // If no params are enabled and body mode is set, default to 'body' tab + // This provides better UX for POST/PUT requests with a body + const request = item.draft?.request || item.request; + const params = request?.params || []; + const bodyMode = request?.body?.mode; + const hasEnabledParams = params.some((p) => p.enabled); + + if (!hasEnabledParams && bodyMode && bodyMode !== 'none') { + return 'body'; + } return 'params'; }