Commit 1543679e authored by Phil Hughes's avatar Phil Hughes

correctly activate the next tab when closing a tab

scroll to the active tab when opening/closing

[ci skip]
parent b4f7496b
import Vue from 'vue';
import flash from '../../flash';
import service from '../services';
import * as types from './mutation_types';
......@@ -99,6 +100,15 @@ export const popHistoryState = ({ state, dispatch, getters }) => {
}
};
export const scrollToTab = () => {
Vue.nextTick(() => {
const tabs = document.getElementById('tabs');
const tabEl = tabs.querySelector('.active');
tabs.scrollLeft = tabEl.offsetLeft;
});
};
export * from './actions/tree';
export * from './actions/file';
export * from './actions/branch';
import flash from '../../../flash';
import service from '../../services';
import * as types from '../mutation_types';
import { createTemp } from '../utils';
import {
createTemp,
findIndexOfFile,
} from '../utils';
export const closeFile = ({ commit }, file) => {
export const closeFile = ({ commit, state, dispatch }, file) => {
if (file.changed || file.tempFile) return;
const indexOfClosedFile = findIndexOfFile(state.openFiles, file);
const fileWasActive = file.active;
commit(types.TOGGLE_FILE_OPEN, file);
commit(types.SET_FILE_ACTIVE, { file, active: false });
if (state.openFiles.length > 0 && fileWasActive) {
const nextIndexToOpen = indexOfClosedFile === 0 ? 0 : indexOfClosedFile - 1;
const nextFileToOpen = state.openFiles[nextIndexToOpen];
dispatch('setFileActive', nextFileToOpen);
}
};
export const setFileActive = ({ commit, state, getters }, file) => {
export const setFileActive = ({ commit, state, getters, dispatch }, file) => {
const currentActiveFile = getters.activeFile;
if (currentActiveFile) {
......@@ -18,6 +31,7 @@ export const setFileActive = ({ commit, state, getters }, file) => {
}
commit(types.SET_FILE_ACTIVE, { file, active: true });
dispatch('scrollToTab');
};
export const getFileData = ({ commit, dispatch }, file) => {
......
......@@ -138,6 +138,7 @@
}
#tabs {
position: relative;
flex-shrink: 0;
display: flex;
width: 100%;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment