mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[ML] Fixes job list page index when deleting jobs off last page (#27481)
This commit is contained in:
parent
3f2d08e8da
commit
746ed07505
1 changed files with 6 additions and 5 deletions
|
@ -78,12 +78,13 @@ class JobsListUI extends Component {
|
|||
let list = this.state.jobsSummaryList;
|
||||
list = sortBy(this.state.jobsSummaryList, (item) => item[sortField]);
|
||||
list = (sortDirection === 'asc') ? list : list.reverse();
|
||||
const listLength = list.length;
|
||||
|
||||
let pageStart = (index * size);
|
||||
if (pageStart >= list.length) {
|
||||
// if the page start is larger than the number of items
|
||||
// due to filters being applied, calculate a new page start
|
||||
pageStart = Math.floor(list.length / size) * size;
|
||||
if (pageStart >= listLength && (listLength !== 0)) {
|
||||
// if the page start is larger than the number of items due to
|
||||
// filters being applied or jobs being deleted, calculate a new page start
|
||||
pageStart = Math.floor((listLength - 1) / size) * size;
|
||||
// set the state out of the render cycle
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
|
@ -93,7 +94,7 @@ class JobsListUI extends Component {
|
|||
}
|
||||
return {
|
||||
pageOfItems: list.slice(pageStart, (pageStart + size)),
|
||||
totalItemCount: list.length,
|
||||
totalItemCount: listLength,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue