From 29cd9e4607b644477844ce2abc30fb18e92e5ba6 Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Sun, 9 Jan 2022 22:35:48 +0530 Subject: [PATCH] chore: last tab gets focussed after closing a tab --- packages/grafnode-run/src/providers/Store/reducer.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/grafnode-run/src/providers/Store/reducer.js b/packages/grafnode-run/src/providers/Store/reducer.js index f7c63423e..bcc7b55f4 100644 --- a/packages/grafnode-run/src/providers/Store/reducer.js +++ b/packages/grafnode-run/src/providers/Store/reducer.js @@ -2,6 +2,7 @@ import produce from 'immer'; import {nanoid} from 'nanoid'; import find from 'lodash/find'; import filter from 'lodash/filter'; +import last from 'lodash/last'; import actions from './actions'; import { flattenItems, @@ -93,13 +94,13 @@ const reducer = (state, action) => { }); } - case actions.REQUEST_TAB_CLOSE: { return produce(state, (draft) => { draft.requestTabs = filter(draft.requestTabs, (rt) => rt.id !== action.requestTab.id); if(draft.requestTabs && draft.requestTabs.length) { - draft.activeRequestTabId = draft.requestTabs[0].id; + // todo: closing tab needs to focus on the right adjacent tab + draft.activeRequestTabId = last(draft.requestTabs).id; } else { draft.activeRequestTabId = null; }