Skip to content

Commit

Permalink
fixed tab close issue (opensearch-project#265)
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Wei <[email protected]>
  • Loading branch information
mengweieric authored Nov 18, 2021
1 parent bfd6129 commit d79f01a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion public/components/common/search/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ export const Search = (props: any) => {
handleQuerySearch={handleQuerySearch}
dslService={dslService}
/>
<EuiBadge className={`ppl-link ${uiSettingsService.get('theme:darkMode') ? "ppl-link-dark" : "ppl-link-light"}`} color="hollow" onClick={() => showFlyout()}>
<EuiBadge
className={`ppl-link ${uiSettingsService.get('theme:darkMode') ? "ppl-link-dark" : "ppl-link-light"}`}
color="hollow"
onClick={() => showFlyout()}
onClickAriaLabel={"pplLinkShowFlyout"}
>
PPL
</EuiBadge>
</EuiFlexItem>
Expand Down
6 changes: 4 additions & 2 deletions public/components/explorer/log_explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ export const LogExplorer = ({
const queryRef = useRef();
const tabIdsRef = useRef();
const explorerDataRef = useRef();
const curSelectedTabIdRef = useRef();
queryRef.current = queries;
tabIdsRef.current = tabIds;
explorerDataRef.current = explorerData;
curSelectedTabIdRef.current = curSelectedTabId;

const [tabCreatedTypes, setTabCreatedTypes] = useState({});


// Append add-new-tab link to the end of the tab list, and remove it once tabs state changes
useEffect(() => {
const addNewLink = $('<a class="linkNewTag">+ Add new</a>').on('click', () => {
Expand All @@ -78,8 +79,9 @@ export const LogExplorer = ({
}

const index: number = tabIds.indexOf(TabIdToBeClosed);
const curSelectedTab = curSelectedTabIdRef.current;
let newIdToFocus = '';
if (TabIdToBeClosed === curSelectedTabId) {
if (TabIdToBeClosed === curSelectedTab) {
if (index === 0) {
newIdToFocus = tabIds[index + 1];
} else if (index > 0) {
Expand Down

0 comments on commit d79f01a

Please sign in to comment.