From 86c3225039d71770c9492bb3a6f047972afbe094 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Mon, 5 Aug 2024 13:40:38 +0400 Subject: [PATCH 01/19] Fix flaky DataViews list layout e2e tests (#64244) Co-authored-by: Mamaduka Co-authored-by: oandregal --- .../site-editor/dataviews-list-layout-keyboard.spec.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js b/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js index f6b01db63d9118..16cc34ace8a82b 100644 --- a/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js +++ b/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js @@ -76,10 +76,15 @@ test.describe( 'Dataviews List Layout', () => { await page.keyboard.press( 'Tab' ); await page.keyboard.press( 'Tab' ); + const firstItem = page + .getByRole( 'grid' ) + .getByRole( 'button' ) + .first(); + // Make sure the items have loaded before reaching for the 1st item in the list. await expect( page.getByRole( 'grid' ) ).toBeVisible(); await page.keyboard.press( 'Tab' ); - await expect( page.getByLabel( 'Privacy Policy' ) ).toBeFocused(); + await expect( firstItem ).toBeFocused(); // Go to the preview. await page.keyboard.press( 'Tab' ); @@ -91,7 +96,7 @@ test.describe( 'Dataviews List Layout', () => { // Go back to the items list using SHIFT+TAB. await page.keyboard.press( 'Shift+Tab' ); - await expect( page.getByLabel( 'Privacy Policy' ) ).toBeFocused(); + await expect( firstItem ).toBeFocused(); } ); test( 'Navigates the items list via UP/DOWN arrow keys', async ( { From ac9a41867f0fd7d882547b7d5e32e47355acc693 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Mon, 5 Aug 2024 10:50:38 +0100 Subject: [PATCH 02/19] Zoom Out: Add a control to enter and leave zoom out mode (#63870) * Zoom Out: Add a control to enter and leave zoom out mode revert changes Use 100% for desktop and 50% for zoom out update menu items Allow users to set zoom out back to 100% when the patterns tab is open Reset zoom when switching device mode Add text for zoom refactor click handler to a shared function Move in and out of zoom out when resizing below tablet viewport size * save the editing mode in a ref so we can restore it * update logic * Update packages/editor/src/components/preview-dropdown/index.js Co-authored-by: Alex Lende * fix preview selection * remove the experiment * remove disconnected change * make the code more readable * simplify code * remove changes from the rebase * Render a down chevron in the dropdown * don't run the use effect when the mode changes * Remove incorrect comment * Customized spacing for chevron in preview dropdown * minor tweaks * Simplify logic for preview selection and keep in line with editorMode * Allow zoom out inserters if manually select zoom out mode from dropdown * Use desktop icon with 50% for zoom out --------- Co-authored-by: Alex Lende Co-authored-by: Jerry Jones Co-authored-by: Rich Tabor Co-authored-by: scruffian Co-authored-by: jeryj Co-authored-by: richtabor Co-authored-by: ajlende Co-authored-by: annezazu Co-authored-by: jasmussen Co-authored-by: MaggieCabrera Co-authored-by: stokesman Co-authored-by: paaljoachim --- .../src/components/block-tools/index.js | 11 +- .../src/components/iframe/index.js | 6 +- .../block-editor/src/hooks/use-zoom-out.js | 2 +- .../editor/src/components/header/index.js | 3 +- .../src/components/preview-dropdown/index.js | 108 +++++++++++++----- .../components/preview-dropdown/style.scss | 5 + .../src/components/visual-editor/index.js | 14 ++- 7 files changed, 101 insertions(+), 48 deletions(-) diff --git a/packages/block-editor/src/components/block-tools/index.js b/packages/block-editor/src/components/block-tools/index.js index c07adb34e584f3..163c35b54e4381 100644 --- a/packages/block-editor/src/components/block-tools/index.js +++ b/packages/block-editor/src/components/block-tools/index.js @@ -251,12 +251,11 @@ export default function BlockTools( { name="__unstable-block-tools-after" ref={ blockToolbarAfterRef } /> - { window.__experimentalEnableZoomedOutPatternsTab && - isZoomOutMode && ( - - ) } + { isZoomOutMode && ( + + ) } ); diff --git a/packages/block-editor/src/components/iframe/index.js b/packages/block-editor/src/components/iframe/index.js index 3b0bce6d56b403..e7af77920ea127 100644 --- a/packages/block-editor/src/components/iframe/index.js +++ b/packages/block-editor/src/components/iframe/index.js @@ -242,10 +242,8 @@ function Iframe( { const isZoomedOut = scale !== 1; useEffect( () => { - if ( ! isZoomedOut ) { - prevContainerWidth.current = containerWidth; - } - }, [ containerWidth, isZoomedOut ] ); + prevContainerWidth.current = containerWidth; + }, [ containerWidth ] ); const disabledRef = useDisabled( { isDisabled: ! readonly } ); const bodyRef = useMergeRefs( [ diff --git a/packages/block-editor/src/hooks/use-zoom-out.js b/packages/block-editor/src/hooks/use-zoom-out.js index 3ec701cfc4a14d..d0d7d0fd4d71c7 100644 --- a/packages/block-editor/src/hooks/use-zoom-out.js +++ b/packages/block-editor/src/hooks/use-zoom-out.js @@ -49,5 +49,5 @@ export function useZoomOut( zoomOut = true ) { ) { __unstableSetEditorMode( originalEditingMode.current ); } - }, [ __unstableSetEditorMode, zoomOut, mode ] ); + }, [ __unstableGetEditorMode, __unstableSetEditorMode, zoomOut ] ); // Mode is deliberately excluded from the dependencies so that the effect does not run when mode changes. } diff --git a/packages/editor/src/components/header/index.js b/packages/editor/src/components/header/index.js index 2a604229596005..b8eda30c721860 100644 --- a/packages/editor/src/components/header/index.js +++ b/packages/editor/src/components/header/index.js @@ -57,7 +57,6 @@ function Header( { showIconLabels, hasFixedToolbar, isNestedEntity, - isZoomedOutView, } = useSelect( ( select ) => { const { get: getPreference } = select( preferencesStore ); const { @@ -136,7 +135,7 @@ function Header( { ) } { - const { getDeviceType, getCurrentPostType } = select( editorStore ); - const { getUnstableBase, getPostType } = select( coreStore ); - const { get } = select( preferencesStore ); - const _currentPostType = getCurrentPostType(); - return { - deviceType: getDeviceType(), - homeUrl: getUnstableBase()?.home, - isTemplate: _currentPostType === 'wp_template', - isViewable: getPostType( _currentPostType )?.viewable ?? false, - showIconLabels: get( 'core', 'showIconLabels' ), - }; - }, [] ); + const { + deviceType, + editorMode, + homeUrl, + isTemplate, + isViewable, + showIconLabels, + } = useSelect( ( select ) => { + const { getDeviceType, getCurrentPostType } = select( editorStore ); + const { getUnstableBase, getPostType } = select( coreStore ); + const { get } = select( preferencesStore ); + const { __unstableGetEditorMode } = select( blockEditorStore ); + const _currentPostType = getCurrentPostType(); + return { + deviceType: getDeviceType(), + editorMode: __unstableGetEditorMode(), + homeUrl: getUnstableBase()?.home, + isTemplate: _currentPostType === 'wp_template', + isViewable: getPostType( _currentPostType )?.viewable ?? false, + showIconLabels: get( 'core', 'showIconLabels' ), + }; + }, [] ); const { setDeviceType } = useDispatch( editorStore ); + const { __unstableSetEditorMode } = useDispatch( blockEditorStore ); + + /** + * Save the original editing mode in a ref to restore it when we exit zoom out. + */ + const originalEditingMode = useRef( editorMode ); + useEffect( () => { + if ( editorMode !== 'zoom-out' ) { + originalEditingMode.current = editorMode; + } + + return () => { + if ( + editorMode === 'zoom-out' && + editorMode !== originalEditingMode.current + ) { + __unstableSetEditorMode( originalEditingMode.current ); + } + }; + }, [ editorMode, __unstableSetEditorMode ] ); + const isMobile = useViewportMatch( 'medium', '<' ); if ( isMobile ) { return null; @@ -48,6 +84,7 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) { }; const toggleProps = { className: 'editor-preview-dropdown__toggle', + iconPosition: 'right', size: 'compact', showTooltip: ! showIconLabels, disabled, @@ -58,9 +95,9 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) { }; const deviceIcons = { + desktop, mobile, tablet, - desktop, }; /** @@ -74,6 +111,11 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) { label: __( 'Desktop' ), icon: desktop, }, + { + value: 'ZoomOut', + label: __( 'Desktop (50%)' ), + icon: desktop, + }, { value: 'Tablet', label: __( 'Tablet' ), @@ -86,29 +128,37 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) { }, ]; + const previewValue = editorMode === 'zoom-out' ? 'ZoomOut' : deviceType; + /** - * The selected choice. + * Handles the selection of a device type. * - * @type {Object} + * @param {string} value The device type. */ - let selectedChoice = choices.find( - ( choice ) => choice.value === deviceType - ); + const onSelect = ( value ) => { + let newEditorMode = originalEditingMode.current; - /** - * If no selected choice is found, default to the first - */ - if ( ! selectedChoice ) { - selectedChoice = choices[ 0 ]; - } + if ( value === 'ZoomOut' ) { + newEditorMode = 'zoom-out'; + setDeviceType( 'Desktop' ); + } else { + setDeviceType( value ); + } + + __unstableSetEditorMode( newEditorMode ); + }; return ( @@ -117,8 +167,8 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) { { isTemplate && ( diff --git a/packages/editor/src/components/preview-dropdown/style.scss b/packages/editor/src/components/preview-dropdown/style.scss index 43fa7cdd8ecd97..c117a4239e9dfb 100644 --- a/packages/editor/src/components/preview-dropdown/style.scss +++ b/packages/editor/src/components/preview-dropdown/style.scss @@ -1,3 +1,8 @@ +.editor-preview-dropdown .editor-preview-dropdown__toggle.has-icon.has-text { + padding-right: 4px; + padding-left: 6px; +} + .editor-preview-dropdown__button-external { width: 100%; display: flex; diff --git a/packages/editor/src/components/visual-editor/index.js b/packages/editor/src/components/visual-editor/index.js index 8b4877704f5f18..a67feb530e96a2 100644 --- a/packages/editor/src/components/visual-editor/index.js +++ b/packages/editor/src/components/visual-editor/index.js @@ -107,6 +107,7 @@ function VisualEditor( { } ) { const [ resizeObserver, sizes ] = useResizeObserver(); const isMobileViewport = useViewportMatch( 'small', '<' ); + const isTabletViewport = useViewportMatch( 'medium', '<' ); const { renderingMode, postContentAttributes, @@ -341,12 +342,13 @@ function VisualEditor( { } ), ] ); - const zoomOutProps = isZoomOutMode - ? { - scale: 'default', - frameSize: '48px', - } - : {}; + const zoomOutProps = + isZoomOutMode && ! isTabletViewport + ? { + scale: 'default', + frameSize: '48px', + } + : {}; const forceFullHeight = postType === NAVIGATION_POST_TYPE; const enableResizing = From 645ae89fb622c4a32aedf79391df1ccd66395dcd Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Mon, 5 Aug 2024 11:54:18 +0200 Subject: [PATCH 03/19] Update: De-emphasise bulk actions on Grid layout. (#64209) Co-authored-by: jorgefilipecosta Co-authored-by: jameskoster Co-authored-by: annezazu Co-authored-by: jasmussen Co-authored-by: ellatrix Co-authored-by: youknowriad --- packages/base-styles/_z-index.scss | 3 +++ packages/dataviews/src/layouts/grid/index.tsx | 16 +++++++-------- .../dataviews/src/layouts/grid/style.scss | 20 +++++++++++++++++++ 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/packages/base-styles/_z-index.scss b/packages/base-styles/_z-index.scss index b8a9088cfd72cc..4d5f22e02fa7d1 100644 --- a/packages/base-styles/_z-index.scss +++ b/packages/base-styles/_z-index.scss @@ -208,6 +208,9 @@ $z-layers: ( // Ensure checkbox + actions don't overlap table header ".dataviews-view-table thead": 1, + // Ensure selection checkbox stays above the preview field. + ".dataviews-view-grid__card .dataviews-selection-checkbox": 1, + // Ensure quick actions toolbar appear above pagination ".dataviews-bulk-actions-toolbar": 2, ); diff --git a/packages/dataviews/src/layouts/grid/index.tsx b/packages/dataviews/src/layouts/grid/index.tsx index cbfccf5521a812..c8cac31bf7db81 100644 --- a/packages/dataviews/src/layouts/grid/index.tsx +++ b/packages/dataviews/src/layouts/grid/index.tsx @@ -84,18 +84,18 @@ function GridItem< Item >( {
{ renderedMediaField }
+ - { renderedPrimaryField } diff --git a/packages/dataviews/src/layouts/grid/style.scss b/packages/dataviews/src/layouts/grid/style.scss index a707401972cdab..ebe039ea7543b0 100644 --- a/packages/dataviews/src/layouts/grid/style.scss +++ b/packages/dataviews/src/layouts/grid/style.scss @@ -9,6 +9,7 @@ .dataviews-view-grid__card { height: 100%; justify-content: flex-start; + position: relative; .dataviews-view-grid__title-actions { padding: $grid-unit-10 0 $grid-unit-05; @@ -22,6 +23,11 @@ .dataviews-view-grid__fields .dataviews-view-grid__field .dataviews-view-grid__field-value { color: $gray-900; } + + .dataviews-view-grid__media::after { + background-color: rgba(var(--wp-admin-theme-color--rgb), 0.08); + box-shadow: inset 0 0 0 $border-width var(--wp-admin-theme-color); + } } } @@ -32,6 +38,7 @@ background-color: $gray-100; border-radius: $grid-unit-05; position: relative; + overflow: hidden; img { object-fit: cover; @@ -148,3 +155,16 @@ .dataviews-view-grid__field:empty { display: none; } + +.dataviews-view-grid__card .dataviews-selection-checkbox { + position: absolute; + top: -9999em; + left: $grid-unit-10; + z-index: z-index(".dataviews-view-grid__card .dataviews-selection-checkbox"); +} + +.dataviews-view-grid__card:hover .dataviews-selection-checkbox, +.dataviews-view-grid__card:focus-within .dataviews-selection-checkbox, +.dataviews-view-grid__card.is-selected .dataviews-selection-checkbox { + top: $grid-unit-10; +} From 4be49120a16cd79066d6528f25f7d10c046026c1 Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Mon, 5 Aug 2024 12:33:29 +0200 Subject: [PATCH 04/19] Move filter UI into a toggle-able panel to improve experience on narrow viewports/containers (#63203) Co-authored-by: jorgefilipecosta Co-authored-by: ntsekouras Co-authored-by: jameskoster Co-authored-by: youknowriad Co-authored-by: jasmussen Co-authored-by: SaxonF --- .../dataviews-filters/add-filter.tsx | 58 +++-- .../components/dataviews-filters/index.tsx | 210 +++++++++++++----- .../components/dataviews-filters/style.scss | 30 +++ .../src/components/dataviews-search/index.tsx | 13 +- .../src/components/dataviews/index.tsx | 26 ++- .../src/components/dataviews/style.scss | 7 +- .../src/components/page-patterns/index.js | 1 + .../src/components/page-templates/index.js | 1 + .../src/components/post-list/index.js | 8 +- .../dataviews-list-layout-keyboard.spec.js | 9 - .../site-editor/new-templates-list.spec.js | 2 +- test/e2e/specs/site-editor/patterns.spec.js | 8 + 12 files changed, 266 insertions(+), 107 deletions(-) diff --git a/packages/dataviews/src/components/dataviews-filters/add-filter.tsx b/packages/dataviews/src/components/dataviews-filters/add-filter.tsx index 38dda38c96e70f..ca1043d6e99fdb 100644 --- a/packages/dataviews/src/components/dataviews-filters/add-filter.tsx +++ b/packages/dataviews/src/components/dataviews-filters/add-filter.tsx @@ -32,29 +32,18 @@ interface AddFilterProps { setOpenedFilter: ( filter: string | null ) => void; } -function AddFilter( - { filters, view, onChangeView, setOpenedFilter }: AddFilterProps, - ref: Ref< HTMLButtonElement > -) { - if ( ! filters.length || filters.every( ( { isPrimary } ) => isPrimary ) ) { - return null; - } +export function AddFilterDropdownMenu( { + filters, + view, + onChangeView, + setOpenedFilter, + trigger, +}: AddFilterProps & { + trigger: React.ReactNode; +} ) { const inactiveFilters = filters.filter( ( filter ) => ! filter.isVisible ); return ( - - { __( 'Add filter' ) } - - } - > + { inactiveFilters.map( ( filter ) => { return ( +) { + if ( ! filters.length || filters.every( ( { isPrimary } ) => isPrimary ) ) { + return null; + } + const inactiveFilters = filters.filter( ( filter ) => ! filter.isVisible ); + return ( + + { __( 'Add filter' ) } + + } + { ...{ filters, view, onChangeView, setOpenedFilter } } + /> + ); +} + export default forwardRef( AddFilter ); diff --git a/packages/dataviews/src/components/dataviews-filters/index.tsx b/packages/dataviews/src/components/dataviews-filters/index.tsx index 449e0ff0323a8b..de3477914c0083 100644 --- a/packages/dataviews/src/components/dataviews-filters/index.tsx +++ b/packages/dataviews/src/components/dataviews-filters/index.tsx @@ -1,65 +1,150 @@ /** * WordPress dependencies */ -import { memo, useContext, useRef } from '@wordpress/element'; -import { __experimentalHStack as HStack } from '@wordpress/components'; +import { + memo, + useContext, + useRef, + useMemo, + useCallback, +} from '@wordpress/element'; +import { __experimentalHStack as HStack, Button } from '@wordpress/components'; +import { funnel } from '@wordpress/icons'; +import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ import FilterSummary from './filter-summary'; -import AddFilter from './add-filter'; +import { default as AddFilter, AddFilterDropdownMenu } from './add-filter'; import ResetFilters from './reset-filters'; import DataViewsContext from '../dataviews-context'; import { sanitizeOperators } from '../../utils'; import { ALL_OPERATORS, OPERATOR_IS, OPERATOR_IS_NOT } from '../../constants'; -import type { NormalizedFilter } from '../../types'; +import type { NormalizedFilter, NormalizedField, View } from '../../types'; -function Filters() { - const { fields, view, onChangeView, openedFilter, setOpenedFilter } = - useContext( DataViewsContext ); - const addFilterRef = useRef< HTMLButtonElement >( null ); - const filters: NormalizedFilter[] = []; - fields.forEach( ( field ) => { - if ( ! field.elements?.length ) { - return; - } +export function useFilters( fields: NormalizedField< any >[], view: View ) { + return useMemo( () => { + const filters: NormalizedFilter[] = []; + fields.forEach( ( field ) => { + if ( ! field.elements?.length ) { + return; + } - const operators = sanitizeOperators( field ); - if ( operators.length === 0 ) { - return; - } + const operators = sanitizeOperators( field ); + if ( operators.length === 0 ) { + return; + } - const isPrimary = !! field.filterBy?.isPrimary; - filters.push( { - field: field.id, - name: field.label, - elements: field.elements, - singleSelection: operators.some( ( op ) => - [ OPERATOR_IS, OPERATOR_IS_NOT ].includes( op ) - ), - operators, - isVisible: - isPrimary || - !! view.filters?.some( - ( f ) => - f.field === field.id && - ALL_OPERATORS.includes( f.operator ) + const isPrimary = !! field.filterBy?.isPrimary; + filters.push( { + field: field.id, + name: field.label, + elements: field.elements, + singleSelection: operators.some( ( op ) => + [ OPERATOR_IS, OPERATOR_IS_NOT ].includes( op ) ), - isPrimary, + operators, + isVisible: + isPrimary || + !! view.filters?.some( + ( f ) => + f.field === field.id && + ALL_OPERATORS.includes( f.operator ) + ), + isPrimary, + } ); } ); - } ); - // Sort filters by primary property. We need the primary filters to be first. - // Then we sort by name. - filters.sort( ( a, b ) => { - if ( a.isPrimary && ! b.isPrimary ) { - return -1; - } - if ( ! a.isPrimary && b.isPrimary ) { - return 1; - } - return a.name.localeCompare( b.name ); - } ); + // Sort filters by primary property. We need the primary filters to be first. + // Then we sort by name. + filters.sort( ( a, b ) => { + if ( a.isPrimary && ! b.isPrimary ) { + return -1; + } + if ( ! a.isPrimary && b.isPrimary ) { + return 1; + } + return a.name.localeCompare( b.name ); + } ); + return filters; + }, [ fields, view ] ); +} + +export function FilterVisibilityToggle( { + filters, + view, + onChangeView, + setOpenedFilter, + isShowingFilter, + setIsShowingFilter, +}: { + filters: NormalizedFilter[]; + view: View; + onChangeView: ( view: View ) => void; + setOpenedFilter: ( filter: string | null ) => void; + isShowingFilter: boolean; + setIsShowingFilter: React.Dispatch< React.SetStateAction< boolean > >; +} ) { + const onChangeViewWithFilterVisibility = useCallback( + ( _view: View ) => { + onChangeView( _view ); + setIsShowingFilter( true ); + }, + [ onChangeView, setIsShowingFilter ] + ); + const visibleFilters = filters.filter( ( filter ) => filter.isVisible ); + + const hasVisibleFilters = !! visibleFilters.length; + if ( ! hasVisibleFilters ) { + return ( + + } + /> + ); + } + return ( +
+
+ ); +} + +function Filters() { + const { fields, view, onChangeView, openedFilter, setOpenedFilter } = + useContext( DataViewsContext ); + const addFilterRef = useRef< HTMLButtonElement >( null ); + const filters = useFilters( fields, view ); const addFilter = ( ); + const visibleFilters = filters.filter( ( filter ) => filter.isVisible ); + if ( visibleFilters.length === 0 ) { + return null; + } const filterComponents = [ - ...filters.map( ( filter ) => { - if ( ! filter.isVisible ) { - return null; - } - + ...visibleFilters.map( ( filter ) => { return ( 1 ) { - filterComponents.push( - - ); - } + filterComponents.push( + + ); return ( - + { filterComponents } ); diff --git a/packages/dataviews/src/components/dataviews-filters/style.scss b/packages/dataviews/src/components/dataviews-filters/style.scss index 26e5e613fcbe44..6912b5cc483164 100644 --- a/packages/dataviews/src/components/dataviews-filters/style.scss +++ b/packages/dataviews/src/components/dataviews-filters/style.scss @@ -2,6 +2,10 @@ position: relative; } +.dataviews-filters__container { + padding-top: 0; +} + .dataviews-filters__reset-button.dataviews-filters__reset-button[aria-disabled="true"] { &, &:hover { @@ -250,3 +254,29 @@ width: $icon-size; } } + +.dataviews-filters__container-visibility-toggle { + position: relative; + flex-shrink: 0; +} + +.dataviews-filters-toggle__count { + position: absolute; + top: 0; + right: 0; + transform: translate(50%, -50%); + background: var(--wp-admin-theme-color, #3858e9); + height: $grid-unit-20; + min-width: $grid-unit-20; + line-height: $grid-unit-20; + padding: 0 $grid-unit-05; + text-align: center; + border-radius: $grid-unit-10; + font-size: 11px; + outline: var(--wp-admin-border-width-focus) solid $white; + color: $white; +} + +.dataviews-search { + width: fit-content; +} diff --git a/packages/dataviews/src/components/dataviews-search/index.tsx b/packages/dataviews/src/components/dataviews-search/index.tsx index 5e5ce705e11195..1aef99872960be 100644 --- a/packages/dataviews/src/components/dataviews-search/index.tsx +++ b/packages/dataviews/src/components/dataviews-search/index.tsx @@ -30,15 +30,18 @@ const DataViewsSearch = memo( function Search( { label }: SearchProps ) { viewRef.current = view; }, [ onChangeView, view ] ); useEffect( () => { - onChangeViewRef.current( { - ...viewRef.current, - page: 1, - search: debouncedSearch, - } ); + if ( debouncedSearch !== viewRef.current?.search ) { + onChangeViewRef.current( { + ...viewRef.current, + page: 1, + search: debouncedSearch, + } ); + } }, [ debouncedSearch ] ); const searchLabel = label || __( 'Search' ); return ( ( { }: DataViewsProps< Item > ) { const [ selectionState, setSelectionState ] = useState< string[] >( [] ); const [ density, setDensity ] = useState< number >( 0 ); + const [ isShowingFilter, setIsShowingFilter ] = + useState< boolean >( false ); const isUncontrolled = selectionProperty === undefined || onChangeSelection === undefined; const selection = isUncontrolled ? selectionState : selectionProperty; @@ -90,6 +96,7 @@ export default function DataViews< Item >( { ); }, [ selection, data, getItemId ] ); + const filters = useFilters( _fields, view ); return ( ( { alignment="top" justify="start" className="dataviews__view-actions" + spacing={ 1 } > - + { search && } - + { view.type === LAYOUT_GRID && ( ( { { header } + { isShowingFilter && } diff --git a/packages/dataviews/src/components/dataviews/style.scss b/packages/dataviews/src/components/dataviews/style.scss index 6b8af6a90007dd..742c8c42134dfd 100644 --- a/packages/dataviews/src/components/dataviews/style.scss +++ b/packages/dataviews/src/components/dataviews/style.scss @@ -9,7 +9,8 @@ flex-direction: column; } -.dataviews__view-actions { +.dataviews__view-actions, +.dataviews-filters__container { box-sizing: border-box; padding: $grid-unit-20 $grid-unit-60; flex-shrink: 0; @@ -78,7 +79,8 @@ /* stylelint-disable-next-line scss/at-rule-no-unknown -- '@container' not globally permitted */ @container (max-width: 430px) { - .dataviews__view-actions { + .dataviews__view-actions, + .dataviews-filters__container { padding: $grid-unit-15 $grid-unit-30; .components-search-control { @@ -95,3 +97,4 @@ padding-right: $grid-unit-30; } } + diff --git a/packages/edit-site/src/components/page-patterns/index.js b/packages/edit-site/src/components/page-patterns/index.js index a8db73272c0ce7..66d2d25a4b8f04 100644 --- a/packages/edit-site/src/components/page-patterns/index.js +++ b/packages/edit-site/src/components/page-patterns/index.js @@ -171,6 +171,7 @@ export default function DataviewsPatterns() { descriptionId={ `${ id }-description` } /> } > { @@ -334,6 +339,7 @@ export default function PostList( { postType } ) { } > { page.getByRole( 'button', { name: 'Add filter' } ) ).toBeFocused(); - await page.keyboard.press( 'Tab' ); - await expect( - page.getByRole( 'button', { name: 'Reset' } ) - ).toBeFocused(); - await page.keyboard.press( 'Tab' ); await expect( page.getByRole( 'button', { name: 'Layout' } ) @@ -74,7 +69,6 @@ test.describe( 'Dataviews List Layout', () => { await page.keyboard.press( 'Tab' ); await page.keyboard.press( 'Tab' ); await page.keyboard.press( 'Tab' ); - await page.keyboard.press( 'Tab' ); const firstItem = page .getByRole( 'grid' ) @@ -109,7 +103,6 @@ test.describe( 'Dataviews List Layout', () => { await page.keyboard.press( 'Tab' ); await page.keyboard.press( 'Tab' ); await page.keyboard.press( 'Tab' ); - await page.keyboard.press( 'Tab' ); // Make sure the items have loaded before reaching for the 1st item in the list. await expect( page.getByRole( 'grid' ) ).toBeVisible(); @@ -133,7 +126,6 @@ test.describe( 'Dataviews List Layout', () => { await page.keyboard.press( 'Tab' ); await page.keyboard.press( 'Tab' ); await page.keyboard.press( 'Tab' ); - await page.keyboard.press( 'Tab' ); // Make sure the items have loaded before reaching for the 1st item in the list. await expect( page.getByRole( 'grid' ) ).toBeVisible(); @@ -175,7 +167,6 @@ test.describe( 'Dataviews List Layout', () => { await page.keyboard.press( 'Tab' ); await page.keyboard.press( 'Tab' ); await page.keyboard.press( 'Tab' ); - await page.keyboard.press( 'Tab' ); // Make sure the items have loaded before reaching for the 1st item in the list. await expect( page.getByRole( 'grid' ) ).toBeVisible(); diff --git a/test/e2e/specs/site-editor/new-templates-list.spec.js b/test/e2e/specs/site-editor/new-templates-list.spec.js index 92edc741011834..878f0ed2eb48c3 100644 --- a/test/e2e/specs/site-editor/new-templates-list.spec.js +++ b/test/e2e/specs/site-editor/new-templates-list.spec.js @@ -56,7 +56,7 @@ test.describe( 'Templates', () => { await expect( titles ).toHaveCount( 1 ); await expect( titles.first() ).toHaveText( 'Tag Archives' ); await page - .getByRole( 'button', { name: 'Reset', exact: true } ) + .getByRole( 'button', { name: 'Reset search', exact: true } ) .click(); await expect( titles ).toHaveCount( 6 ); diff --git a/test/e2e/specs/site-editor/patterns.spec.js b/test/e2e/specs/site-editor/patterns.spec.js index 0b0fada39c2622..538f9ba936a897 100644 --- a/test/e2e/specs/site-editor/patterns.spec.js +++ b/test/e2e/specs/site-editor/patterns.spec.js @@ -148,6 +148,14 @@ test.describe( 'Patterns', () => { await admin.visitSiteEditor( { postType: 'wp_block' } ); await expect( patterns.item ).toHaveCount( 3 ); + + await patterns.content + .getByRole( 'button', { + name: 'Toggle filter display', + exact: true, + } ) + .click(); + const searchBox = patterns.content.getByRole( 'searchbox', { name: 'Search', } ); From 9a3d12aa900de3efcc1f623a170b9d7ee3841933 Mon Sep 17 00:00:00 2001 From: Erik <11491369+kebbet@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:36:34 +0200 Subject: [PATCH 05/19] Data Views: Add context to trash string (#64249) Co-authored-by: kebbet Co-authored-by: Mamaduka --- packages/editor/src/dataviews/actions/trash-post.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/editor/src/dataviews/actions/trash-post.tsx b/packages/editor/src/dataviews/actions/trash-post.tsx index c6a265eba81f5a..a8e42c510a6cd0 100644 --- a/packages/editor/src/dataviews/actions/trash-post.tsx +++ b/packages/editor/src/dataviews/actions/trash-post.tsx @@ -4,7 +4,7 @@ import { trash } from '@wordpress/icons'; import { useDispatch } from '@wordpress/data'; import { store as coreStore } from '@wordpress/core-data'; -import { __, _n, sprintf } from '@wordpress/i18n'; +import { __, _n, sprintf, _x } from '@wordpress/i18n'; import { store as noticesStore } from '@wordpress/notices'; import { useState } from '@wordpress/element'; import { @@ -185,7 +185,7 @@ const trashPost: Action< PostWithPermissions > = { disabled={ isBusy } accessibleWhenDisabled > - { __( 'Trash' ) } + { _x( 'Trash', 'verb' ) }
From 3f7611a8ae36d2fb5159185ea7b759e2b605755f Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Mon, 5 Aug 2024 20:10:35 +0900 Subject: [PATCH 06/19] BlockDraggable: Remove invalid aria-hidden attribute from button (#64228) Co-authored-by: t-hamano Co-authored-by: Mamaduka --- packages/block-editor/src/components/block-mover/index.js | 1 - .../src/components/block-tools/block-selection-button.js | 1 - .../block-editor/src/components/block-tools/zoom-out-toolbar.js | 1 - 3 files changed, 3 deletions(-) diff --git a/packages/block-editor/src/components/block-mover/index.js b/packages/block-editor/src/components/block-mover/index.js index 3b7f25800095a5..7aa273605bbe6b 100644 --- a/packages/block-editor/src/components/block-mover/index.js +++ b/packages/block-editor/src/components/block-mover/index.js @@ -89,7 +89,6 @@ function BlockMover( { - + + + + ); } diff --git a/packages/format-library/src/language/index.js b/packages/format-library/src/language/index.js index d37d8d6dbd0cd8..6cfb8c4ad44927 100644 --- a/packages/format-library/src/language/index.js +++ b/packages/format-library/src/language/index.js @@ -13,6 +13,7 @@ import { Button, Popover, __experimentalHStack as HStack, + __experimentalVStack as VStack, } from '@wordpress/components'; import { useState } from '@wordpress/element'; import { applyFormat, removeFormat, useAnchor } from '@wordpress/rich-text'; @@ -78,7 +79,9 @@ function InlineLanguageUI( { value, contentRef, onChange, onClose } ) { anchor={ popoverAnchor } onClose={ onClose } > -
{ event.preventDefault(); @@ -95,6 +98,8 @@ function InlineLanguageUI( { value, contentRef, onChange, onClose } ) { } } > setLang( val ) } @@ -103,6 +108,8 @@ function InlineLanguageUI( { value, contentRef, onChange, onClose } ) { ) } />