From 81db200a740fdecceecafac5716997749167346c Mon Sep 17 00:00:00 2001
From: chad1008 <13856531+chad1008@users.noreply.github.com>
Date: Thu, 14 Dec 2023 15:33:34 -0500
Subject: [PATCH 01/13] implement Tabs
---
.../src/components/list-view-sidebar/index.js | 78 +++++++++----------
1 file changed, 36 insertions(+), 42 deletions(-)
diff --git a/packages/editor/src/components/list-view-sidebar/index.js b/packages/editor/src/components/list-view-sidebar/index.js
index c369dea6734971..37056fd388d688 100644
--- a/packages/editor/src/components/list-view-sidebar/index.js
+++ b/packages/editor/src/components/list-view-sidebar/index.js
@@ -2,7 +2,10 @@
* WordPress dependencies
*/
import { __experimentalListView as ListView } from '@wordpress/block-editor';
-import { Button, TabPanel } from '@wordpress/components';
+import {
+ Button,
+ privateApis as componentsPrivateApis,
+} from '@wordpress/components';
import { useFocusOnMount, useMergeRefs } from '@wordpress/compose';
import { useDispatch, useSelect } from '@wordpress/data';
import { focus } from '@wordpress/dom';
@@ -19,6 +22,8 @@ import ListViewOutline from './list-view-outline';
import { unlock } from '../../lock-unlock';
import { store as editorStore } from '../../store';
+const { Tabs } = unlock( componentsPrivateApis );
+
export default function ListViewSidebar() {
const { setIsListViewOpened } = useDispatch( editorStore );
const { getListViewToggleRef } = unlock( useSelect( editorStore ) );
@@ -108,22 +113,6 @@ export default function ListViewSidebar() {
// It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.
useShortcut( 'core/editor/toggle-list-view', handleToggleListViewShortcut );
- /**
- * Render tab content for a given tab name.
- *
- * @param {string} tabName The name of the tab to render.
- */
- function renderTabContent( tabName ) {
- if ( tabName === 'list-view' ) {
- return (
-
-
-
- );
- }
- return ;
- }
-
return (
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
-
-
setTab( tabName ) }
- selectOnMove={ false }
- tabs={ [
- {
- name: 'list-view',
- title: _x( 'List View', 'Post overview' ),
- className: 'editor-list-view-sidebar__panel-tab',
- },
- {
- name: 'outline',
- title: _x( 'Outline', 'Post overview' ),
- className: 'editor-list-view-sidebar__panel-tab',
- },
- ] }
>
- { ( currentTab ) => (
+ setTab( tabName ) }
+ >
+
+
+ { _x( 'List View', 'Post overview' ) }
+
+
+ { _x( 'Outline', 'Post overview' ) }
+
+
+
+
- { renderTabContent( currentTab.name ) }
+
+
+
+
+
+
+
+
- ) }
-
+
+
);
}
From 7eddb43b337e6e5542c570636679aae76c7d5af8 Mon Sep 17 00:00:00 2001
From: chad1008 <13856531+chad1008@users.noreply.github.com>
Date: Thu, 14 Dec 2023 15:33:55 -0500
Subject: [PATCH 02/13] update styles
---
.../src/components/list-view-sidebar/style.scss | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/packages/editor/src/components/list-view-sidebar/style.scss b/packages/editor/src/components/list-view-sidebar/style.scss
index 29cc4778e3d4ab..43439d48d1abd3 100644
--- a/packages/editor/src/components/list-view-sidebar/style.scss
+++ b/packages/editor/src/components/list-view-sidebar/style.scss
@@ -17,21 +17,18 @@
background: $white;
}
- // The TabPanel style overrides in the following blocks should be removed when the new TabPanel is available.
- .components-tab-panel__tabs {
+ [role="tablist"] {
border-bottom: $border-width solid $gray-300;
- box-sizing: border-box;
- display: flex;
- width: 100%;
padding-right: $grid-unit-70;
+ box-sizing: border-box;
- .editor-list-view-sidebar__panel-tab {
+ [role="tab"] {
width: 50%;
margin-bottom: -$border-width;
}
}
- .components-tab-panel__tab-content {
+ [role="tabpanel"] {
height: calc(100% - #{$grid-unit-60 - $border-width});
}
}
From cea53c3342d4f38ed3adf18ff609c3231d2b802e Mon Sep 17 00:00:00 2001
From: chad1008 <13856531+chad1008@users.noreply.github.com>
Date: Tue, 19 Dec 2023 14:08:53 -0500
Subject: [PATCH 03/13] fix tab flow and placement styles
---
.../src/components/list-view-sidebar/index.js | 31 ++++++++++---------
.../components/list-view-sidebar/style.scss | 15 ++++-----
2 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/packages/editor/src/components/list-view-sidebar/index.js b/packages/editor/src/components/list-view-sidebar/index.js
index 37056fd388d688..0f9ec11de2f820 100644
--- a/packages/editor/src/components/list-view-sidebar/index.js
+++ b/packages/editor/src/components/list-view-sidebar/index.js
@@ -128,21 +128,22 @@ export default function ListViewSidebar() {
selectOnMove={ false }
onSelect={ ( tabName ) => setTab( tabName ) }
>
-
-
- { _x( 'List View', 'Post overview' ) }
-
-
- { _x( 'Outline', 'Post overview' ) }
-
-
-
-
+
+
+
+
+ { _x( 'List View', 'Post overview' ) }
+
+
+ { _x( 'Outline', 'Post overview' ) }
+
+
+
Date: Tue, 19 Dec 2023 16:59:26 -0500
Subject: [PATCH 04/13] clean up DOM structure
---
.../src/components/list-view-sidebar/index.js | 76 +++++++++----------
1 file changed, 38 insertions(+), 38 deletions(-)
diff --git a/packages/editor/src/components/list-view-sidebar/index.js b/packages/editor/src/components/list-view-sidebar/index.js
index 0f9ec11de2f820..8182a0c583ff0e 100644
--- a/packages/editor/src/components/list-view-sidebar/index.js
+++ b/packages/editor/src/components/list-view-sidebar/index.js
@@ -56,7 +56,7 @@ export default function ListViewSidebar() {
// This ref refers to the sidebar as a whole.
const sidebarRef = useRef();
// This ref refers to the tab panel.
- const tabPanelRef = useRef();
+ const tabsRef = useRef();
// This ref refers to the list view application area.
const listViewRef = useRef();
@@ -76,7 +76,7 @@ export default function ListViewSidebar() {
*/
function handleSidebarFocus( currentTab ) {
// Tab panel focus.
- const tabPanelFocus = focus.tabbable.find( tabPanelRef.current )[ 0 ];
+ const tabPanelFocus = focus.tabbable.find( tabsRef.current )[ 0 ];
// List view tab is selected.
if ( currentTab === 'list-view' ) {
// Either focus the list view or the tab panel. Must have a fallback because the list view does not render when there are no blocks.
@@ -120,45 +120,45 @@ export default function ListViewSidebar() {
onKeyDown={ closeOnEscape }
ref={ sidebarRef }
>
-
setTab( tabName ) }
>
-
setTab( tabName ) }
+
+
+
+
+ { _x( 'List View', 'Post overview' ) }
+
+
+ { _x( 'Outline', 'Post overview' ) }
+
+
+
+
+
-
-
-
-
- { _x( 'List View', 'Post overview' ) }
-
-
- { _x( 'Outline', 'Post overview' ) }
-
-
-
-
+
+
+
+
+
);
}
From 4d7e39c0c2be0af8401890f3a96638cbdbb18c21 Mon Sep 17 00:00:00 2001
From: chad1008 <13856531+chad1008@users.noreply.github.com>
Date: Tue, 19 Dec 2023 17:35:40 -0500
Subject: [PATCH 05/13] enable selectOnMove
---
packages/editor/src/components/list-view-sidebar/index.js | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/packages/editor/src/components/list-view-sidebar/index.js b/packages/editor/src/components/list-view-sidebar/index.js
index 8182a0c583ff0e..273f90c5c0c8b4 100644
--- a/packages/editor/src/components/list-view-sidebar/index.js
+++ b/packages/editor/src/components/list-view-sidebar/index.js
@@ -120,10 +120,7 @@ export default function ListViewSidebar() {
onKeyDown={ closeOnEscape }
ref={ sidebarRef }
>
-
setTab( tabName ) }
- >
+ setTab( tabName ) }>
Date: Tue, 19 Dec 2023 17:36:40 -0500
Subject: [PATCH 06/13] remove old css becuase i forgot in the last commit
---
packages/editor/src/components/list-view-sidebar/style.scss | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/packages/editor/src/components/list-view-sidebar/style.scss b/packages/editor/src/components/list-view-sidebar/style.scss
index b385cbbfe73cbc..cf625f01d05376 100644
--- a/packages/editor/src/components/list-view-sidebar/style.scss
+++ b/packages/editor/src/components/list-view-sidebar/style.scss
@@ -80,3 +80,9 @@
color: $gray-700;
}
}
+
+.edit-post-editor__list-view-container {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+}
From fe4b6dd8e59630c4fc521b7035fdb5783c96e143 Mon Sep 17 00:00:00 2001
From: chad1008 <13856531+chad1008@users.noreply.github.com>
Date: Tue, 2 Jan 2024 17:01:32 -0500
Subject: [PATCH 07/13] re-disable `selectOnMove`
---
packages/editor/src/components/list-view-sidebar/index.js | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/packages/editor/src/components/list-view-sidebar/index.js b/packages/editor/src/components/list-view-sidebar/index.js
index 273f90c5c0c8b4..b6f9723fff4911 100644
--- a/packages/editor/src/components/list-view-sidebar/index.js
+++ b/packages/editor/src/components/list-view-sidebar/index.js
@@ -120,7 +120,10 @@ export default function ListViewSidebar() {
onKeyDown={ closeOnEscape }
ref={ sidebarRef }
>
- setTab( tabName ) }>
+ setTab( tabName ) }
+ selectOnMove={ false }
+ >
Date: Mon, 22 Jan 2024 14:00:24 -0500
Subject: [PATCH 08/13] implement initialTabId value
---
packages/editor/src/components/list-view-sidebar/index.js | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/packages/editor/src/components/list-view-sidebar/index.js b/packages/editor/src/components/list-view-sidebar/index.js
index b6f9723fff4911..c4a00d27738a6b 100644
--- a/packages/editor/src/components/list-view-sidebar/index.js
+++ b/packages/editor/src/components/list-view-sidebar/index.js
@@ -123,6 +123,11 @@ export default function ListViewSidebar() {
setTab( tabName ) }
selectOnMove={ false }
+ // The initial tab value is set explicitly to avoid a an initial
+ // render where no tab is selected. This ensures that the
+ // tabpanel height is correct so the relevant scroll container
+ // can be rendered internally.
+ initialTabId="list-view"
>
Date: Mon, 22 Jan 2024 17:29:16 -0500
Subject: [PATCH 09/13] fix merge conflict errors
---
.../editor/src/components/list-view-sidebar/index.js | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/packages/editor/src/components/list-view-sidebar/index.js b/packages/editor/src/components/list-view-sidebar/index.js
index c4a00d27738a6b..0c7777a782c48f 100644
--- a/packages/editor/src/components/list-view-sidebar/index.js
+++ b/packages/editor/src/components/list-view-sidebar/index.js
@@ -131,7 +131,7 @@ export default function ListViewSidebar() {
>
-
+
-
+
From 7177813ec11e922fc4b1c9adb3a2e6543a7f91d3 Mon Sep 17 00:00:00 2001
From: chad1008 <13856531+chad1008@users.noreply.github.com>
Date: Fri, 26 Jan 2024 13:41:28 -0500
Subject: [PATCH 10/13] incorporate post-rebase feedback
---
packages/editor/src/components/list-view-sidebar/index.js | 6 +++++-
packages/editor/src/components/list-view-sidebar/style.scss | 5 -----
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/packages/editor/src/components/list-view-sidebar/index.js b/packages/editor/src/components/list-view-sidebar/index.js
index 0c7777a782c48f..c350a60168a6ba 100644
--- a/packages/editor/src/components/list-view-sidebar/index.js
+++ b/packages/editor/src/components/list-view-sidebar/index.js
@@ -156,7 +156,11 @@ export default function ListViewSidebar() {
-
+
diff --git a/packages/editor/src/components/list-view-sidebar/style.scss b/packages/editor/src/components/list-view-sidebar/style.scss
index cf625f01d05376..c85a9af93ec5fd 100644
--- a/packages/editor/src/components/list-view-sidebar/style.scss
+++ b/packages/editor/src/components/list-view-sidebar/style.scss
@@ -81,8 +81,3 @@
}
}
-.edit-post-editor__list-view-container {
- display: flex;
- flex-direction: column;
- height: 100%;
-}
From 869bc23199d3366a576b0ab8c191f14ee3990f99 Mon Sep 17 00:00:00 2001
From: chad1008 <13856531+chad1008@users.noreply.github.com>
Date: Fri, 26 Jan 2024 14:13:14 -0500
Subject: [PATCH 11/13] classnames instead of roles
---
.../src/components/list-view-sidebar/index.js | 17 ++++++++++----
.../components/list-view-sidebar/style.scss | 23 ++++++++++---------
2 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/packages/editor/src/components/list-view-sidebar/index.js b/packages/editor/src/components/list-view-sidebar/index.js
index c350a60168a6ba..1333251d55a9dd 100644
--- a/packages/editor/src/components/list-view-sidebar/index.js
+++ b/packages/editor/src/components/list-view-sidebar/index.js
@@ -136,11 +136,20 @@ export default function ListViewSidebar() {
label={ __( 'Close' ) }
onClick={ closeListView }
/>
-
-
+
+
{ _x( 'List View', 'Post overview' ) }
-
+
{ _x( 'Outline', 'Post overview' ) }
@@ -148,7 +157,7 @@ export default function ListViewSidebar() {
diff --git a/packages/editor/src/components/list-view-sidebar/style.scss b/packages/editor/src/components/list-view-sidebar/style.scss
index c85a9af93ec5fd..f2db812c5690e7 100644
--- a/packages/editor/src/components/list-view-sidebar/style.scss
+++ b/packages/editor/src/components/list-view-sidebar/style.scss
@@ -18,20 +18,21 @@
align-self: center;
margin-right: $grid-unit-10;
}
+}
- [role="tablist"] {
- box-sizing: border-box;
- flex-grow: 1;
+.editor-list-view-sidebar__tabs-tablist {
+ box-sizing: border-box;
+ flex-grow: 1;
- [role="tab"] {
- width: 50%;
- margin-bottom: -$border-width;
- }
- }
+}
- [role="tabpanel"] {
- height: calc(100% - #{$grid-unit-60 - $border-width});
- }
+.editor-list-view-sidebar__tabs-tab {
+ width: 50%;
+ margin-bottom: -$border-width;
+}
+
+.editor-list-view-sidebar__tabs-tabpanel {
+ height: calc(100% - #{$grid-unit-60 - $border-width});
}
.editor-list-view-sidebar__list-view-panel-content,
From 3bd148c9cb1aa146831c3e2dd2b14d7708ac7dae Mon Sep 17 00:00:00 2001
From: chad1008 <13856531+chad1008@users.noreply.github.com>
Date: Mon, 29 Jan 2024 16:27:56 -0500
Subject: [PATCH 12/13] fix horizontal scroll bar
---
.../src/components/list-view-sidebar/index.js | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/packages/editor/src/components/list-view-sidebar/index.js b/packages/editor/src/components/list-view-sidebar/index.js
index 1333251d55a9dd..75149ba60fcb77 100644
--- a/packages/editor/src/components/list-view-sidebar/index.js
+++ b/packages/editor/src/components/list-view-sidebar/index.js
@@ -157,20 +157,24 @@ export default function ListViewSidebar() {
-
From 22379707bddf40ee56ce7ee9c97801cde624c6ef Mon Sep 17 00:00:00 2001
From: Chad Chadbourne <13856531+chad1008@users.noreply.github.com>
Date: Mon, 29 Jan 2024 23:49:25 -0500
Subject: [PATCH 13/13] Update
packages/editor/src/components/list-view-sidebar/index.js
Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com>
---
packages/editor/src/components/list-view-sidebar/index.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/editor/src/components/list-view-sidebar/index.js b/packages/editor/src/components/list-view-sidebar/index.js
index 75149ba60fcb77..9484ddcf3943dd 100644
--- a/packages/editor/src/components/list-view-sidebar/index.js
+++ b/packages/editor/src/components/list-view-sidebar/index.js
@@ -123,7 +123,7 @@ export default function ListViewSidebar() {
setTab( tabName ) }
selectOnMove={ false }
- // The initial tab value is set explicitly to avoid a an initial
+ // The initial tab value is set explicitly to avoid an initial
// render where no tab is selected. This ensures that the
// tabpanel height is correct so the relevant scroll container
// can be rendered internally.