mirror of
https://github.com/mathuo/dockview
synced 2025-02-20 15:15:44 +00:00
Merge pull request #300 from mathuo/230-explore-floating-groups
feat: resrict new floating groups if floating with 1 tab
This commit is contained in:
commit
f1357edbb5
@ -577,7 +577,7 @@ describe('tabsContainer', () => {
|
||||
expect(eventPreventDefaultSpy2).toBeCalledTimes(0);
|
||||
});
|
||||
|
||||
test('that selecting a tab which shift down will move that tab into a new floating group', () => {
|
||||
test('that selecting a tab with shift down will move that tab into a new floating group', () => {
|
||||
const accessorMock = jest.fn<DockviewComponent, []>(() => {
|
||||
return (<Partial<DockviewComponent>>{
|
||||
options: {},
|
||||
@ -592,6 +592,7 @@ describe('tabsContainer', () => {
|
||||
const groupPanelMock = jest.fn<DockviewGroupPanel, []>(() => {
|
||||
return (<Partial<DockviewGroupPanel>>{
|
||||
api: { isFloating: true } as any,
|
||||
model: {} as any,
|
||||
}) as DockviewGroupPanel;
|
||||
});
|
||||
|
||||
@ -600,9 +601,9 @@ describe('tabsContainer', () => {
|
||||
|
||||
const cut = new TabsContainer(accessor, groupPanel);
|
||||
|
||||
const panelMock = jest.fn<IDockviewPanel, []>(() => {
|
||||
const panelMock = jest.fn<IDockviewPanel, [string]>((id: string) => {
|
||||
const partial: Partial<IDockviewPanel> = {
|
||||
id: 'test_id',
|
||||
id,
|
||||
|
||||
view: {
|
||||
tab: {
|
||||
@ -615,8 +616,8 @@ describe('tabsContainer', () => {
|
||||
};
|
||||
return partial as IDockviewPanel;
|
||||
});
|
||||
const panel = new panelMock();
|
||||
|
||||
const panel = new panelMock('test_id');
|
||||
cut.openPanel(panel);
|
||||
|
||||
const el = cut.element.querySelector('.tab')!;
|
||||
@ -626,6 +627,14 @@ describe('tabsContainer', () => {
|
||||
const preventDefaultSpy = jest.spyOn(event, 'preventDefault');
|
||||
fireEvent(el, event);
|
||||
|
||||
// a floating group with a single tab shouldn't be eligible
|
||||
expect(preventDefaultSpy).toBeCalledTimes(0);
|
||||
expect(accessor.addFloatingGroup).toBeCalledTimes(0);
|
||||
|
||||
const panel2 = new panelMock('test_id_2');
|
||||
cut.openPanel(panel2);
|
||||
fireEvent(el, event);
|
||||
|
||||
expect(preventDefaultSpy).toBeCalledTimes(1);
|
||||
expect(accessor.addFloatingGroup).toBeCalledTimes(1);
|
||||
});
|
||||
|
@ -296,7 +296,14 @@ export class TabsContainer
|
||||
const isFloatingGroupsEnabled =
|
||||
!this.accessor.options.disableFloatingGroups;
|
||||
|
||||
if (isFloatingGroupsEnabled && event.shiftKey) {
|
||||
const isFloatingWithOnePanel =
|
||||
this.group.api.isFloating && this.size === 1;
|
||||
|
||||
if (
|
||||
isFloatingGroupsEnabled &&
|
||||
!isFloatingWithOnePanel &&
|
||||
event.shiftKey
|
||||
) {
|
||||
event.preventDefault();
|
||||
|
||||
const panel = this.accessor.getGroupPanel(tabToAdd.panelId);
|
||||
|
Loading…
Reference in New Issue
Block a user