From e38347dfd46f898b0d019090973c480c3d64c0b3 Mon Sep 17 00:00:00 2001 From: dalemcgrew Date: Sun, 18 Feb 2024 19:30:56 -0800 Subject: [PATCH] Fixed problem with ability to see more ballot items on Ballot page. Fixed a few ESLINT warnings/errors. Turned off RepresentativeList when no data found. --- .../components/Campaign/CampaignListRoot.jsx | 12 ++ .../Ballot/BallotItemCompressed.jsx | 4 +- .../Ballot/OfficeItemCompressed.jsx | 49 ++++---- .../CandidateListRoot/CandidateListRoot.jsx | 25 ++-- src/js/components/Friends/AskFriendsModal.jsx | 2 +- .../RepresentativeListRoot.jsx | 15 ++- src/js/components/Search/SearchBar.jsx | 2 +- .../VoterGuide/OrganizationVoterGuideTabs.jsx | 2 +- .../Widgets/FriendsOnlyIndicator.jsx | 14 +-- src/js/pages/Campaigns/CampaignsHome.jsx | 114 ++++++++++++++---- 10 files changed, 168 insertions(+), 71 deletions(-) diff --git a/src/js/common/components/Campaign/CampaignListRoot.jsx b/src/js/common/components/Campaign/CampaignListRoot.jsx index 71e0b3e4c..5acec2bd8 100644 --- a/src/js/common/components/Campaign/CampaignListRoot.jsx +++ b/src/js/common/components/Campaign/CampaignListRoot.jsx @@ -77,6 +77,17 @@ class CampaignListRoot extends Component { this.campaignStoreListener.remove(); } + handleNumberOfResults (numberOfFilteredResults, numberOfSearchResults) { + // console.log('RepresentativeListRoot handleNumberOfResults numberOfFilteredResults:', numberOfFilteredResults, ', numberOfSearchResults:', numberOfSearchResults); + if (this.props.handleNumberOfResults) { + // Delay telling the parent component that the number of results has changed + // if (this.timer) clearTimeout(this.timer); + // this.timer = setTimeout(() => { + this.props.handleNumberOfResults(numberOfFilteredResults, numberOfSearchResults); + // }, 500); + } + } + onCampaignSupporterStoreChange () { // We need to instantiate CampaignSupporterStore before we call campaignListRetrieve so that store gets filled with data } @@ -358,6 +369,7 @@ class CampaignListRoot extends Component { } CampaignListRoot.propTypes = { classes: PropTypes.object, + handleNumberOfResults: PropTypes.func, hideCampaignsLinkedToPoliticians: PropTypes.bool, hideIfNoResults: PropTypes.bool, hideTitle: PropTypes.bool, diff --git a/src/js/components/Ballot/BallotItemCompressed.jsx b/src/js/components/Ballot/BallotItemCompressed.jsx index ff6dcb4fc..b95ee6423 100644 --- a/src/js/components/Ballot/BallotItemCompressed.jsx +++ b/src/js/components/Ballot/BallotItemCompressed.jsx @@ -10,7 +10,7 @@ export default class BallotItemCompressed extends PureComponent { const { ballotItemDisplayName, candidateList, candidatesToShowForSearchResults, isFirstBallotItem, isMeasure, - totalNumberOfBallotItems, weVoteId, + weVoteId, } = this.props; return (
@@ -26,7 +26,6 @@ export default class BallotItemCompressed extends PureComponent { candidateList={candidateList} candidatesToShowForSearchResults={candidatesToShowForSearchResults} isFirstBallotItem={isFirstBallotItem} - totalNumberOfBallotItems={totalNumberOfBallotItems} /> )}
@@ -39,6 +38,5 @@ BallotItemCompressed.propTypes = { candidatesToShowForSearchResults: PropTypes.array, isFirstBallotItem: PropTypes.bool, isMeasure: PropTypes.bool, - totalNumberOfBallotItems: PropTypes.number, weVoteId: PropTypes.string.isRequired, }; diff --git a/src/js/components/Ballot/OfficeItemCompressed.jsx b/src/js/components/Ballot/OfficeItemCompressed.jsx index ae11e58be..1b11a1f51 100644 --- a/src/js/components/Ballot/OfficeItemCompressed.jsx +++ b/src/js/components/Ballot/OfficeItemCompressed.jsx @@ -31,7 +31,6 @@ const IssuesByBallotItemDisplayList = React.lazy(() => import(/* webpackChunkNam const ItemActionBar = React.lazy(() => import(/* webpackChunkName: 'ItemActionBar' */ '../Widgets/ItemActionBar/ItemActionBar')); const ShowMoreButtons = React.lazy(() => import(/* webpackChunkName: 'ShowMoreButtons' */ '../Widgets/ShowMoreButtons')); -const SHOW_ALL_CANDIDATES_IF_FEWER_THAN_THIS_NUMBER_OF_BALLOT_ITEMS = 5; const NUMBER_OF_CANDIDATES_TO_DISPLAY = 3; // This is related to components/VoterGuide/VoterGuideOfficeItemCompressed @@ -43,7 +42,6 @@ class OfficeItemCompressed extends Component { this.state = { candidateListLength: 0, candidateListForDisplay: [], - limitNumberOfCandidatesShownToThisNumber: NUMBER_OF_CANDIDATES_TO_DISPLAY, organizationWeVoteId: '', positionListFromFriendsHasBeenRetrievedOnce: {}, positionListHasBeenRetrievedOnce: {}, @@ -199,14 +197,6 @@ class OfficeItemCompressed extends Component { let sortedCandidateList = {}; if (candidateListForDisplay && candidateListForDisplay.length) { sortedCandidateList = sortCandidateList(candidateListForDisplay); - const { totalNumberOfBallotItems } = this.props; - const limitCandidatesShownBecauseMoreThanDefaultNumberOfBallotItems = (totalNumberOfBallotItems && totalNumberOfBallotItems > SHOW_ALL_CANDIDATES_IF_FEWER_THAN_THIS_NUMBER_OF_BALLOT_ITEMS); - if (!limitCandidatesShownBecauseMoreThanDefaultNumberOfBallotItems) { - // If the ballot is only show 5 ballot items, then don't limit the number of candidates we show - this.setState({ - limitNumberOfCandidatesShownToThisNumber: candidateList.length, - }); - } } this.setState({ candidateListForDisplay: sortedCandidateList, @@ -262,12 +252,18 @@ class OfficeItemCompressed extends Component { const { candidateList } = this.props; let { candidatesToShowForSearchResults } = this.props; candidatesToShowForSearchResults = candidatesToShowForSearchResults || []; - const { candidateListForDisplay, showAllCandidates } = this.state; + const { showAllCandidates } = this.state; const supportedCandidatesList = candidateList.filter((candidate) => candidatesToShowForSearchResults.includes(candidate.we_vote_id) || (SupportStore.getVoterSupportsByBallotItemWeVoteId(candidate.we_vote_id) && !candidate.withdrawn_from_election)); const opposedCandidatesList = candidateList.filter((candidate) => candidatesToShowForSearchResults.includes(candidate.we_vote_id) || (SupportStore.getVoterOpposesByBallotItemWeVoteId(candidate.we_vote_id) && !candidate.withdrawn_from_election)); const supportedAndOpposedCandidatesList = supportedCandidatesList.concat(opposedCandidatesList); - const candidatesToRender = (supportedCandidatesList.length && !showAllCandidates) ? supportedAndOpposedCandidatesList : candidateListForDisplay; - return candidatesToRender.length; + // console.log('OfficeItemCompressed getCandidatesToRenderCount candidatesToRender: ', candidatesToRender); + if (showAllCandidates) { + return candidateList.length; + } else if (supportedAndOpposedCandidatesList && supportedAndOpposedCandidatesList.length > 0) { + return supportedAndOpposedCandidatesList.length; + } else { + return NUMBER_OF_CANDIDATES_TO_DISPLAY; + } } // eslint-disable-next-line no-unused-vars @@ -275,14 +271,24 @@ class OfficeItemCompressed extends Component { const { candidateList, externalUniqueId, isFirstBallotItem } = this.props; let { candidatesToShowForSearchResults } = this.props; candidatesToShowForSearchResults = candidatesToShowForSearchResults || []; - const { candidateListForDisplay, limitNumberOfCandidatesShownToThisNumber, showAllCandidates } = this.state; + const { candidateListForDisplay, showAllCandidates } = this.state; // limitNumberOfCandidatesShownToThisNumber // If voter has chosen 1+ candidates, only show those const supportedCandidatesList = candidateList.filter((candidate) => candidatesToShowForSearchResults.includes(candidate.we_vote_id) || (SupportStore.getVoterSupportsByBallotItemWeVoteId(candidate.we_vote_id) && !candidate.withdrawn_from_election)); const opposedCandidatesList = candidateList.filter((candidate) => candidatesToShowForSearchResults.includes(candidate.we_vote_id) || (SupportStore.getVoterOpposesByBallotItemWeVoteId(candidate.we_vote_id) && !candidate.withdrawn_from_election)); const supportedAndOpposedCandidatesList = supportedCandidatesList.concat(opposedCandidatesList); // If there are supported candidates, then limit what we show to supported and opposed candidates - const candidatesToRender = (supportedCandidatesList.length && !showAllCandidates) ? supportedAndOpposedCandidatesList : candidateListForDisplay; - const candidatesToRenderLength = candidatesToRender.length; + let candidatesToRender; + let limitNumberOfCandidatesShownToThisNumber; + if (showAllCandidates) { + candidatesToRender = candidateList; + limitNumberOfCandidatesShownToThisNumber = candidatesToRender.length; + } else if (supportedAndOpposedCandidatesList && supportedAndOpposedCandidatesList.length > 0) { + candidatesToRender = supportedAndOpposedCandidatesList; + limitNumberOfCandidatesShownToThisNumber = candidatesToRender.length; + } else { + candidatesToRender = candidateListForDisplay; + limitNumberOfCandidatesShownToThisNumber = NUMBER_OF_CANDIDATES_TO_DISPLAY; + } const hideItemActionBar = false; const hideCandidateDetails = false; // supportedCandidatesList.length; let candidateCount = 0; @@ -450,7 +456,8 @@ class OfficeItemCompressed extends Component { - {((candidateCount < candidatesToRenderLength) && (candidateCount < limitNumberOfCandidatesShownToThisNumber)) && ( + {/* {((candidateCount < candidatesToRenderLength) && (candidateCount < limitNumberOfCandidatesShownToThisNumber)) && ( */} + {(candidateCount < limitNumberOfCandidatesShownToThisNumber) && (
@@ -464,14 +471,12 @@ class OfficeItemCompressed extends Component { showAllCandidates () { this.setState({ - limitNumberOfCandidatesShownToThisNumber: 99, showAllCandidates: true, }); } showLessCandidates () { this.setState({ - limitNumberOfCandidatesShownToThisNumber: NUMBER_OF_CANDIDATES_TO_DISPLAY, showAllCandidates: false, }, () => { this.targetRef.scrollIntoView({ @@ -513,9 +518,6 @@ class OfficeItemCompressed extends Component { const { isFirstBallotItem, officeWeVoteId } = this.props; // classes const { candidateListLength, showAllCandidates, totalNumberOfCandidates } = this.state; ballotItemDisplayName = toTitleCase(ballotItemDisplayName); - // const supportedCandidatesList = candidateList.filter((candidate) => (SupportStore.getVoterSupportsByBallotItemWeVoteId(candidate.we_vote_id) && !candidate.withdrawn_from_election)); - // const thereIsAtLeastOneSupportedCandidate = supportedCandidatesList.length > 0; - // Even if voter has chosen 1+ candidates, show the "Show more" link const candidatesToRenderCount = this.getCandidatesToRenderCount(); const moreCandidatesToDisplay = (candidatesToRenderCount < totalNumberOfCandidates); // console.log('ballotItemDisplayName:', ballotItemDisplayName, ', candidatesToRenderCount:', candidatesToRenderCount, ', totalNumberOfCandidates:', totalNumberOfCandidates, ', moreCandidatesToDisplay:', moreCandidatesToDisplay); @@ -534,7 +536,7 @@ class OfficeItemCompressed extends Component { {ballotItemDisplayName} {/* ************************* - Display either a) the candidates the voter supports, or b) the first several candidates running for this office + Display either a) the candidates the voter supports, or b) the first few candidates running for this office ************************* */} {this.generateCandidates(officeWeVoteId)} @@ -574,7 +576,6 @@ OfficeItemCompressed.propTypes = { isFirstBallotItem: PropTypes.bool, organization: PropTypes.object, organizationWeVoteId: PropTypes.string, - totalNumberOfBallotItems: PropTypes.number, }; const styles = (theme) => ({ diff --git a/src/js/components/CandidateListRoot/CandidateListRoot.jsx b/src/js/components/CandidateListRoot/CandidateListRoot.jsx index 896177e15..8a5a167bb 100644 --- a/src/js/components/CandidateListRoot/CandidateListRoot.jsx +++ b/src/js/components/CandidateListRoot/CandidateListRoot.jsx @@ -104,6 +104,17 @@ class CandidateListRoot extends Component { this.candidateStoreListener.remove(); } + handleNumberOfResults (numberOfFilteredResults, numberOfSearchResults) { + // console.log('RepresentativeListRoot handleNumberOfResults numberOfFilteredResults:', numberOfFilteredResults, ', numberOfSearchResults:', numberOfSearchResults); + if (this.props.handleNumberOfResults) { + // Delay telling the parent component that the number of results has changed + // if (this.timer) clearTimeout(this.timer); + // this.timer = setTimeout(() => { + this.props.handleNumberOfResults(numberOfFilteredResults, numberOfSearchResults); + // }, 500); + } + } + onCandidateStoreChange () { this.onIncomingListChange(); } @@ -255,7 +266,7 @@ class CandidateListRoot extends Component { filteredList = filteredList.sort(this.orderByUltimateElectionDate); let searchResults = []; let hideDisplayBecauseNoSearchResults = false; - this.callbackToParentHideIfNoResults(false); + // this.callbackToParentHideIfNoResults(false); if (searchText && searchText.length > 0) { const searchTextLowercase = searchText.toLowerCase(); // console.log('searchTextLowercase:', searchTextLowercase); @@ -288,7 +299,7 @@ class CandidateListRoot extends Component { }); if (searchResults.length === 0) { hideDisplayBecauseNoSearchResults = true; - this.callbackToParentHideIfNoResults(true); + // this.callbackToParentHideIfNoResults(true); } if (searchResults.length > 0) { // Only allow the first politician entry to be displayed (when there are multiple candidate entries for the same politician) @@ -327,7 +338,7 @@ class CandidateListRoot extends Component { filteredList, hideDisplayBecauseNoSearchResults, timeStampOfChange: Date.now(), - }); + }, () => { this.handleNumberOfResults(filteredList.length, searchResults.length); }); } leftAndRightArrowSetState = (el) => { @@ -351,9 +362,9 @@ class CandidateListRoot extends Component { }); } - callbackToParentHideIfNoResults = (newValue) => { - this.props.onHideIfNoResultsChange(newValue); - } + // callbackToParentHideIfNoResults = (newValue) => { + // this.props.onHideIfNoResultsChange(newValue); + // } render () { renderLog('CandidateListRoot'); // Set LOG_RENDER_EVENTS to log all renders @@ -438,8 +449,8 @@ class CandidateListRoot extends Component { } CandidateListRoot.propTypes = { classes: PropTypes.object, + handleNumberOfResults: PropTypes.func, hideIfNoResults: PropTypes.bool, - onHideIfNoResultsChange: PropTypes.func, hideTitle: PropTypes.bool, incomingList: PropTypes.array, incomingListTimeStampOfChange: PropTypes.number, diff --git a/src/js/components/Friends/AskFriendsModal.jsx b/src/js/components/Friends/AskFriendsModal.jsx index 1074fe907..9f4265c15 100644 --- a/src/js/components/Friends/AskFriendsModal.jsx +++ b/src/js/components/Friends/AskFriendsModal.jsx @@ -178,7 +178,7 @@ class AskFriendsModal extends Component { const { location: { pathname } } = window; const { currentFriendListFilteredBySearch, electionDateInFutureFormatted, - electionDateIsToday, numberOfItemsToDisplay, searchFilterOn, searchTerm, + electionDateIsToday, numberOfItemsToDisplay, searchFilterOn, totalCurrentFriendListCount, } = this.state; let { currentFriendList } = this.state; diff --git a/src/js/components/RepresentativeListRoot/RepresentativeListRoot.jsx b/src/js/components/RepresentativeListRoot/RepresentativeListRoot.jsx index 19005ab96..f2848a945 100644 --- a/src/js/components/RepresentativeListRoot/RepresentativeListRoot.jsx +++ b/src/js/components/RepresentativeListRoot/RepresentativeListRoot.jsx @@ -99,6 +99,18 @@ class RepresentativeListRoot extends Component { componentWillUnmount () { this.representativeStoreListener.remove(); + if (this.timer) clearTimeout(this.timer); + } + + handleNumberOfResults (numberOfFilteredResults, numberOfSearchResults) { + // console.log('RepresentativeListRoot handleNumberOfResults numberOfFilteredResults:', numberOfFilteredResults, ', numberOfSearchResults:', numberOfSearchResults); + if (this.props.handleNumberOfResults) { + // Delay telling the parent component that the number of results has changed + // if (this.timer) clearTimeout(this.timer); + // this.timer = setTimeout(() => { + this.props.handleNumberOfResults(numberOfFilteredResults, numberOfSearchResults); + // }, 500); + } } onRepresentativeStoreChange () { @@ -336,7 +348,7 @@ class RepresentativeListRoot extends Component { hideDisplayBecauseNoSearchResults, representativeSearchResults: searchResults, timeStampOfChange: Date.now(), - }); + }, () => { this.handleNumberOfResults(filteredList.length, searchResults.length); }); } leftAndRightArrowSetState = (el) => { @@ -439,6 +451,7 @@ class RepresentativeListRoot extends Component { } RepresentativeListRoot.propTypes = { classes: PropTypes.object, + handleNumberOfResults: PropTypes.func, hideIfNoResults: PropTypes.bool, hideTitle: PropTypes.bool, incomingList: PropTypes.array, diff --git a/src/js/components/Search/SearchBar.jsx b/src/js/components/Search/SearchBar.jsx index f2ae9dab7..62006ec60 100644 --- a/src/js/components/Search/SearchBar.jsx +++ b/src/js/components/Search/SearchBar.jsx @@ -132,4 +132,4 @@ SearchBar.propTypes = { const SearchInput = styled('input')` ${isIPhoneMiniOrSmaller() ? 'font-size: 0.8rem' : ''}; -`; \ No newline at end of file +`; diff --git a/src/js/components/VoterGuide/OrganizationVoterGuideTabs.jsx b/src/js/components/VoterGuide/OrganizationVoterGuideTabs.jsx index b4d69e64d..88d5c649c 100644 --- a/src/js/components/VoterGuide/OrganizationVoterGuideTabs.jsx +++ b/src/js/components/VoterGuide/OrganizationVoterGuideTabs.jsx @@ -62,7 +62,7 @@ export default class OrganizationVoterGuideTabs extends Component { VoterGuideActions.voterGuideFollowersRetrieve(organizationWeVoteId); VoterGuideActions.voterGuidesRecommendedByOrganizationRetrieve(organizationWeVoteId, VoterStore.electionId()); // Positions for this organization, for this voter / election - OrganizationActions.positionListForOpinionMaker(organizationWeVoteId, true); // Needed for friends + OrganizationActions.positionListForOpinionMaker(organizationWeVoteId, true, false); // Needed for friends // Positions for this organization, NOT including for this voter / election OrganizationActions.positionListForOpinionMaker(organizationWeVoteId, false, true); // New call for all positions diff --git a/src/js/components/Widgets/FriendsOnlyIndicator.jsx b/src/js/components/Widgets/FriendsOnlyIndicator.jsx index 6543d9039..9fa902cf3 100644 --- a/src/js/components/Widgets/FriendsOnlyIndicator.jsx +++ b/src/js/components/Widgets/FriendsOnlyIndicator.jsx @@ -12,13 +12,14 @@ const groupIcon = '../../../img/global/svg-icons/group-icon.svg'; const publicIcon = '../../../img/global/svg-icons/public-icon.svg'; -export default function FriendsOnlyIndicator({ isFriendsOnly }){ +export default function FriendsOnlyIndicator ({ isFriendsOnlyIncoming }) { renderLog('FriendsOnlyIndicator'); // Set LOG_RENDER_EVENTS to log all renders - + + let isFriendsOnly = isFriendsOnlyIncoming; let labelText = ''; let visibilityIcon = ''; - if (isFriendsOnly === undefined) { + if (isFriendsOnlyIncoming === undefined) { isFriendsOnly = true; } @@ -71,11 +72,10 @@ export default function FriendsOnlyIndicator({ isFriendsOnly }){ {visibilityIcon} ); - -}; +} FriendsOnlyIndicator.propTypes = { - isFriendsOnly: PropTypes.bool, + isFriendsOnlyIncoming: PropTypes.bool, }; const PublicFriendsIndicator = styled('span')` @@ -83,4 +83,4 @@ const PublicFriendsIndicator = styled('span')` display: inline-block; margin-top: -5px; height: 18px; -`; \ No newline at end of file +`; diff --git a/src/js/pages/Campaigns/CampaignsHome.jsx b/src/js/pages/Campaigns/CampaignsHome.jsx index 63648e6d6..30149be8a 100644 --- a/src/js/pages/Campaigns/CampaignsHome.jsx +++ b/src/js/pages/Campaigns/CampaignsHome.jsx @@ -52,13 +52,22 @@ class CampaignsHome extends Component { candidateListTimeStampOfChange: 0, filterYear: 0, isSearching: false, - hideIfNoResults: true, listModeShown: 'showUpcomingEndorsements', listModeFiltersAvailable: [], listModeFiltersTimeStampOfChange: 0, // listOfYearsWhenCampaignExists: [], // listOfYearsWhenCandidateExists: [], listOfYearsWhenRepresentativeExists: [], + numberOfCampaignResults: 99, + numberOfCampaignSearchResults: 0, + numberOfCandidatesOnBallotResults: 99, + numberOfCandidatesOnBallotSearchResults: 0, + numberOfCloseRacesResults: 99, + numberOfCloseRacesSearchResults: 0, + numberOfMorePoliticiansResults: 99, + numberOfMorePoliticiansSearchResults: 0, + numberOfRepresentativeResults: 99, + numberOfRepresentativeSearchResults: 0, politicianWeVoteIdsAlreadyShown: [], representativeListOnYourBallot: [], representativeListShownAsRepresentatives: [], @@ -626,8 +635,39 @@ class CampaignsHome extends Component { } } - handleHideIfNoResultsChange = (newValue) => { - this.setState({ hideIfNoResults: newValue }); + handleNumberOfCampaignResults = (listResults, searchResults) => { + this.setState({ + numberOfCampaignResults: listResults, + numberOfCampaignSearchResults: searchResults, + }); + } + + handleNumberOfCandidatesOnBallotResults = (listResults, searchResults) => { + this.setState({ + numberOfCandidatesOnBallotResults: listResults, + numberOfCandidatesOnBallotSearchResults: searchResults, + }); + } + + handleNumberOfCloseRacesResults = (listResults, searchResults) => { + this.setState({ + numberOfCloseRacesResults: listResults, + numberOfCloseRacesSearchResults: searchResults, + }); + } + + handleNumberOfMorePoliticiansResults = (listResults, searchResults) => { + this.setState({ + numberOfMorePoliticiansResults: listResults, + numberOfMorePoliticiansSearchResults: searchResults, + }); + } + + handleNumberOfRepresentativeResults = (listResults, searchResults) => { + this.setState({ + numberOfRepresentativeResults: listResults, + numberOfRepresentativeSearchResults: searchResults, + }); } render () { @@ -639,11 +679,19 @@ class CampaignsHome extends Component { candidateListIsBattleground, candidateListOnYourBallot, detailsListMode, filterYear, isSearching, listModeFiltersAvailable, listModeFiltersTimeStampOfChange, + numberOfCampaignResults, numberOfCampaignSearchResults, + numberOfCandidatesOnBallotResults, numberOfCandidatesOnBallotSearchResults, + numberOfCloseRacesResults, numberOfCloseRacesSearchResults, + numberOfMorePoliticiansResults, numberOfMorePoliticiansSearchResults, + numberOfRepresentativeResults, numberOfRepresentativeSearchResults, representativeListOnYourBallot, representativeListShownAsRepresentatives, representativeListTimeStampOfChange, searchText, stateCode, } = this.state; + // const numberOfAnyResults = numberOfCampaignResults + numberOfCandidatesOnBallotResults + numberOfCloseRacesResults + numberOfMorePoliticiansResults + numberOfRepresentativeResults; + const numberOfSearchResults = numberOfCampaignSearchResults + numberOfCandidatesOnBallotSearchResults + numberOfCloseRacesSearchResults + numberOfMorePoliticiansSearchResults + numberOfRepresentativeSearchResults; + // console.log('CampaignsHome render numberOfAnyResults:', numberOfAnyResults, ', numberOfSearchResults:', numberOfSearchResults); // console.log('CampaignsHomeLoader.jsx render campaignList:', campaignList); - const pigCanFly = false; + const pigsCanFly = false; if (detailsListMode) { // console.log('detailsListMode TRUE'); @@ -659,13 +707,13 @@ class CampaignsHome extends Component { searchText={searchText} stateCode={stateCode} /> - {nextReleaseFeaturesEnabled && ( - + {(nextReleaseFeaturesEnabled && pigsCanFly) && ( +  }> 0) || (representativeListShownAsRepresentatives && representativeListShownAsRepresentatives.length > 0); const otherTitlesShown = (campaignsShowing && nextReleaseFeaturesEnabled) || (candidateListOnYourBallot && candidateListOnYourBallot.length > 0) || (candidateListIsBattleground && candidateListIsBattleground.length > 0) || representativesShowing; - const useMinimumBattlegroundHeight = this.useMinimumBattlegroundHeightForState(stateCode); + // const useMinimumBattlegroundHeight = this.useMinimumBattlegroundHeightForState(stateCode); const displayBattlegroundPlaceholder = this.displayBattlegroundPlaceholderForState(stateCode); + // console.log('CampaignsHome, isSearching: ', isSearching, 'numberOfRepresentativeResults:', numberOfRepresentativeResults); return ( - {((this.state.hideIfNoResults)) && ( + {(isSearching && numberOfSearchResults === 0) && ( )} - {(nextReleaseFeaturesEnabled && pigCanFly) && ( + {(nextReleaseFeaturesEnabled && pigsCanFly) && ( }> )} {(candidateListIsBattleground && candidateListIsBattleground.length > 0) ? ( - + 0}> + {/* Was useMinimumBattlegroundHeight */} }> )} {(representativeListShownAsRepresentatives && representativeListShownAsRepresentatives.length > 0) ? ( - + 0}> }> ) : ( - + <> + {numberOfRepresentativeResults > 0 && ( + <> + CandidateListRootPlaceholder + + + )} + )} {(candidateListOnYourBallot && candidateListOnYourBallot.length > 0) ? ( - + 0}> }> ) : ( - + <> + {numberOfCandidatesOnBallotResults > 0 && ( + <> + + + )} + )} - + 0}> }> - + {/* */} {/* */} - {pigCanFly && ( + {pigsCanFly && ( }>