Skip to content

Commit

Permalink
Hide sort direction control if there is no sortable fields
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Aug 27, 2024
1 parent 482c188 commit 467a27b
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,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 467a27b

Please sign in to comment.