Skip to content

Commit e67c564

Browse files
committed
Candidates scroll and loader fixes
1 parent 42ae084 commit e67c564

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

src/components/map-projects/Candidates.jsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Mappings from './Mappings'
1818
import Concept from './Concept'
1919
import IncludeRetired from './IncludeRetired'
2020

21-
const CandidateList = ({candidates, header, rowIndex, orderBy, order, onOrderChange, setShowItem, showItem, setShowHighlights, isSelectedForMap, onMap, onFetchMore, canFetchMore}) => {
21+
const CandidateList = ({candidates, header, rowIndex, orderBy, order, onOrderChange, setShowItem, showItem, setShowHighlights, isSelectedForMap, onMap, onFetchMore, canFetchMore, isLoading}) => {
2222
const results = {total: onFetchMore ? candidates.length : 1, results: candidates || []}
2323

2424
return candidates.length > 0 ? (
@@ -73,8 +73,8 @@ const CandidateList = ({candidates, header, rowIndex, orderBy, order, onOrderCha
7373
{
7474
onFetchMore && canFetchMore &&
7575
<div className='col-xs-12' style={{textAlign: 'right', margin: '16px 0'}}>
76-
<Button size='small' variant='text' sx={{textTransform: 'none'}} onClick={onFetchMore}>
77-
Fetch More
76+
<Button disabled={isLoading} size='small' variant='text' sx={{textTransform: 'none'}} onClick={onFetchMore}>
77+
{isLoading ? 'Fetching...' : 'Fetch More'}
7878
</Button>
7979
</div>
8080
}
@@ -96,7 +96,8 @@ const Candidates = ({rowIndex, alert, setAlert, candidates, orderBy, order, onOr
9696
order: order,
9797
onOrderChange: onOrderChange,
9898
setShowItem: setShowItem,
99-
showItem: showItem
99+
showItem: showItem,
100+
isLoading: isLoading
100101
}
101102
return (
102103
<div className='col-xs-12 padding-0'>
@@ -133,17 +134,18 @@ const Candidates = ({rowIndex, alert, setAlert, candidates, orderBy, order, onOr
133134
'& ul': { padding: 0 },
134135
}}
135136
subheader={<li />}
137+
id='candidates-list'
136138
>
137139
<li>
138140
{
139-
isLoading ?
141+
(isLoading && !recommended?.length) ?
140142
<Skeleton height={60} /> :
141143
<CandidateList {...props} candidates={recommended} header='Recommended Candidates' canFetchMore={canFetchMore && !available?.length} onFetchMore={onFetchMore} />
142144
}
143145
</li>
144146
<li>
145147
{
146-
isLoading ?
148+
(isLoading && !available?.length) ?
147149
<Skeleton height={60} /> :
148150
<CandidateList {...props} candidates={available} header='Available Candidates' canFetchMore={canFetchMore} onFetchMore={onFetchMore} />
149151
}

src/components/map-projects/MapProject.jsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ const MapProject = () => {
10681068
fetchOtherCandidates(null, 0, newRetired)
10691069
}
10701070

1071-
const fetchOtherCandidates = (_row, offset=0, _retired) => {
1071+
const fetchOtherCandidates = (_row, offset=0, _retired, scrollToBottom) => {
10721072
setAlert(false)
10731073
if(isAnyValidColumn()) {
10741074
let __row = isEmpty(_row) ? row : _row
@@ -1104,6 +1104,13 @@ const MapProject = () => {
11041104
const synonyms = get(payload, 'rows.0.synonyms')
11051105
setTimeout(() => highlightTexts(items, null, false, compact([get(payload, 'rows.0.name'), ...(isArray(synonyms) ? synonyms : [synonyms])])), 100)
11061106
}
1107+
if(scrollToBottom) {
1108+
setTimeout(() => {
1109+
const el = document.getElementById('candidates-list')
1110+
if(el)
1111+
el.scrollTo({ top: el.scrollHeight, behavior: 'smooth' });
1112+
}, 100)
1113+
}
11071114
});
11081115
} else {
11091116
setAlert({message: 'None of the columns are valid for matching, please edit and assign valid columns.'})
@@ -1113,7 +1120,7 @@ const MapProject = () => {
11131120

11141121
const onFetchMoreCandidates = () => {
11151122
const currentResults = find(otherMatchedConcepts, matched => matched.row.__index === rowIndex)?.results?.length || 0
1116-
fetchOtherCandidates(null, currentResults)
1123+
fetchOtherCandidates(null, currentResults, undefined, true)
11171124
}
11181125

11191126
const search = (event, page, pageSize, includeRetired, appliedFilters) => {

0 commit comments

Comments
 (0)