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

[WooCommerce] Fix unable to review Installed Themes in MyTheme tab #86944

Merged
merged 5 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion client/my-sites/themes/themes-selection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ class ThemesSelection extends Component {
};

componentDidMount() {
if ( this.props.isRequesting || this.props.isLastPage ) {
return;
}

// Create "buffer zone" to prevent overscrolling too early bugging pagination requests.
const { query } = this.props;
if ( ! query.search && ! query.filter && ! query.tier ) {
Expand Down Expand Up @@ -304,7 +308,7 @@ export const ConnectedThemesSelection = connect(
) => {
const isAtomic = isSiteAutomatedTransfer( state, siteId );
const premiumThemesEnabled = arePremiumThemesEnabled( state, siteId );
const hiddenFilters = getThemeHiddenFilters( state, siteId );
const hiddenFilters = getThemeHiddenFilters( state, siteId, tabFilter );
const hasUnlimitedPremiumThemes = siteHasFeature(
state,
siteId,
Expand Down
13 changes: 5 additions & 8 deletions client/my-sites/themes/themes-toolbar-group/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ const ThemesToolbarGroup: React.FC< ThemesToolbarGroupProps > = ( {
selectedKey,
onSelect,
} ) => {
const activeIndex = useMemo(
() =>
Math.max(
items.findIndex( ( { key } ) => key === selectedKey ),
0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the filter tab doesn't have a match, it should not display any active tab, instead of defaulting to an active index of 0.

),
[ items, selectedKey ]
);
const activeIndex = useMemo( () => {
const index = items.findIndex( ( { key } ) => key === selectedKey );
// If the selected key is not found, return undefined to disable the active state.
return index >= 0 ? index : undefined;
}, [ items, selectedKey ] );

return (
<ResponsiveToolbarGroup
Expand Down
7 changes: 5 additions & 2 deletions client/state/themes/selectors/get-theme-hidden-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import { isSiteOnECommerceTrial, isSiteOnWooExpress } from 'calypso/state/sites/
* Returns theme filters that are not shown in the UI nor navigation URL.
* @param {Object} state Global state tree
* @param {?number} siteId Site ID to optionally use as context
* @param {?string} tabFilter Tab filter to optionally use as context
* @returns {Array} Array of filter slugs
*/
export function getThemeHiddenFilters( state, siteId ) {
export function getThemeHiddenFilters( state, siteId, tabFilter ) {
const filters = [];
const isECommerceTrialOrWooExpress =
isSiteOnECommerceTrial( state, siteId ) || isSiteOnWooExpress( state, siteId );

if ( isSiteOnECommerceTrial( state, siteId ) || isSiteOnWooExpress( state, siteId ) ) {
if ( isECommerceTrialOrWooExpress && tabFilter === 'recommended' ) {
filters.push( 'store' );
}

Expand Down
Loading