Skip to content

Commit

Permalink
Fix display of fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed Jan 3, 2023
1 parent e7323c2 commit b3bd27b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
9 changes: 1 addition & 8 deletions searchlib/components/RenderSlot/RenderSlot.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
/**
* This is a big "switch"
*/
// import React from 'react';

import { SEARCH_STATE_IDS } from '@eeacms/search/constants';

export default function RenderSlot(props) {
const { slotName, searchState } = props;
const anyStateId = `${slotName}-${SEARCH_STATE_IDS.any}`;
const byStateId = `${slotName}-${SEARCH_STATE_IDS[searchState]}`;

const anyState = props[anyStateId];
const byState = props[byStateId];

const res = props[slotName] || byState || anyState || null;
const res = props[slotName] || byState || null;
return res;
}
2 changes: 1 addition & 1 deletion searchlib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const SEARCH_STATE_IDS = {
};

export const SEARCH_STATES = [
[SEARCH_STATE_IDS.any, 'Always'],
[SEARCH_STATE_IDS.any, 'Any state'],
[SEARCH_STATE_IDS.isLandingPage, 'Landing page'],
[SEARCH_STATE_IDS.hasResults, 'Has results'],
[SEARCH_STATE_IDS.hasNoResults, 'Has no results'],
Expand Down
6 changes: 5 additions & 1 deletion src/SearchBlock/templates/FullView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ function FullView(props) {
selected={false}
block={blockId}
mode={mode}
data={slotFills?.[blockId]}
data={
slotFills?.[blockId] || mode === 'view'
? slotFills?.[`${blockId.split('-')[0]}-any`]
: null
}
onChangeSlotfill={onChangeSlotfill}
onDeleteSlotfill={onDeleteSlotfill}
onSelectSlotfill={onSelectSlotfill}
Expand Down

0 comments on commit b3bd27b

Please sign in to comment.