Skip to content

Commit

Permalink
DataViews: hide sort direction control if there is no sortable fields (
Browse files Browse the repository at this point in the history
…#64817)

Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
  • Loading branch information
3 people authored and artemiomorales committed Aug 28, 2024
1 parent d86a6c7 commit 8d564f7
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ function SortFieldControl() {

function SortDirectionControl() {
const { view, fields, onChangeView } = useContext( DataViewsContext );

const sortableFields = fields.filter(
( field ) => field.enableSorting !== false
);
if ( sortableFields.length === 0 ) {
return null;
}

let value = view.sort?.direction;
if ( ! value && view.sort?.field ) {
value = 'desc';
Expand Down

0 comments on commit 8d564f7

Please sign in to comment.