Skip to content

Commit

Permalink
Fix: Omit default parameters from pages, template parts, and patterns (
Browse files Browse the repository at this point in the history
…WordPress#62372)

Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
  • Loading branch information
3 people authored Jun 6, 2024
1 parent 044a05f commit 6831711
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ export default function DataViewItem( {
const iconToUse =
icon || VIEW_LAYOUTS.find( ( v ) => v.type === type ).icon;

let activeView = isCustom ? customViewId : slug;
if ( activeView === 'all' ) {
activeView = undefined;
}
const linkInfo = useLink( {
postType,
layout,
activeView: isCustom ? customViewId : slug,
isCustom: isCustom ? 'true' : 'false',
activeView,
isCustom: isCustom ? 'true' : undefined,
} );
return (
<HStack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
*/
import SidebarNavigationItem from '../sidebar-navigation-item';
import { useLink } from '../routes/link';
import { TEMPLATE_PART_POST_TYPE, PATTERN_TYPES } from '../../utils/constants';
import {
TEMPLATE_PART_POST_TYPE,
TEMPLATE_PART_ALL_AREAS_CATEGORY,
PATTERN_DEFAULT_CATEGORY,
PATTERN_TYPES,
} from '../../utils/constants';

export default function CategoryItem( {
count,
Expand All @@ -14,7 +19,11 @@ export default function CategoryItem( {
type,
} ) {
const linkInfo = useLink( {
categoryId: id,
categoryId:
id !== TEMPLATE_PART_ALL_AREAS_CATEGORY &&
id !== PATTERN_DEFAULT_CATEGORY
? id
: undefined,
postType:
type === TEMPLATE_PART_POST_TYPE
? TEMPLATE_PART_POST_TYPE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@ export default function SidebarNavigationScreenPatterns( { backPath } ) {
const {
params: { postType, categoryId },
} = useLocation();
const currentCategory = categoryId || PATTERN_DEFAULT_CATEGORY;
const currentType = postType || PATTERN_TYPES.user;
const currentCategory =
categoryId ||
( currentType === PATTERN_TYPES.user
? PATTERN_DEFAULT_CATEGORY
: TEMPLATE_PART_ALL_AREAS_CATEGORY );

const { templatePartAreas, hasTemplateParts, isLoading } =
useTemplatePartAreas();
Expand Down

0 comments on commit 6831711

Please sign in to comment.