Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query Pagination: address feedback from #50779 #51165

Merged
merged 4 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions packages/block-library/src/query-pagination-next/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ export default function QueryPaginationNextEdit( {
onClick={ ( event ) => event.preventDefault() }
{ ...useBlockProps() }
>
<PlainText
__experimentalVersion={ 2 }
tagName="span"
aria-label={ __( 'Next page link' ) }
placeholder={ showLabel ? __( 'Next Page' ) : '' }
value={ showLabel ? label : '' }
onChange={ ( newLabel ) =>
setAttributes( { label: newLabel } )
}
/>
{ showLabel && (
<PlainText
__experimentalVersion={ 2 }
tagName="span"
aria-label={ __( 'Next page link' ) }
placeholder={ __( 'Next Page' ) }
value={ label }
onChange={ ( newLabel ) =>
setAttributes( { label: newLabel } )
}
/>
) }
{ displayArrow && (
<span
className={ `wp-block-query-pagination-next-arrow is-arrow-${ paginationArrow }` }
Expand Down
22 changes: 12 additions & 10 deletions packages/block-library/src/query-pagination-previous/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ export default function QueryPaginationPreviousEdit( {
{ displayArrow }
</span>
) }
<PlainText
__experimentalVersion={ 2 }
tagName="span"
aria-label={ __( 'Previous page link' ) }
placeholder={ showLabel ? __( 'Previous Page' ) : '' }
value={ showLabel ? label : '' }
onChange={ ( newLabel ) =>
setAttributes( { label: newLabel } )
}
/>
{ showLabel && (
<PlainText
__experimentalVersion={ 2 }
tagName="span"
aria-label={ __( 'Previous page link' ) }
placeholder={ __( 'Previous Page' ) }
value={ label }
onChange={ ( newLabel ) =>
setAttributes( { label: newLabel } )
}
/>
) }
</a>
);
}
9 changes: 6 additions & 3 deletions packages/block-library/src/query-pagination/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';
import { PanelBody } from '@wordpress/components';
import { useEffect } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -53,9 +54,11 @@ export default function QueryPaginationEdit( {
allowedBlocks: ALLOWED_BLOCKS,
} );
// Always show label text if paginationArrow is set to 'none'.
if ( paginationArrow === 'none' ) {
setAttributes( { showLabel: true } );
}
useEffect( () => {
if ( paginationArrow === 'none' ) {
mikachan marked this conversation as resolved.
Show resolved Hide resolved
setAttributes( { showLabel: true } );
}
}, [ paginationArrow, setAttributes ] );
mikachan marked this conversation as resolved.
Show resolved Hide resolved
return (
<>
{ hasNextPreviousBlocks && (
Expand Down