Skip to content

Commit

Permalink
Fix global table indexing
Browse files Browse the repository at this point in the history
fix brave#4741

Auditors: @bsclifton

Test Plan:
1. go to about:history
2. sort the table
3. multi select entries
4. right click on them
5. perform any actions in context menu
6. the action tagets should be correct
  • Loading branch information
darkdh committed Oct 13, 2016
1 parent 689b48b commit 00f7026
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions js/components/sortableTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ class SortableTable extends ImmutableComponent {
entry.className = entry.className.replace(' selected', '')
const tableID = entry.id
const index = entry.rowIndex - 1
const globalIndex = parseInt(entry.getAttribute('data-global-index'))
const handlerInput = this.props.totalRowObjects
? (typeof this.props.totalRowObjects[parseInt(tableID)][index].toJS === 'function'
? this.props.totalRowObjects[parseInt(tableID)][index].toJS()
: this.props.totalRowObjects[parseInt(tableID)][index])
? (typeof this.props.totalRowObjects[parseInt(tableID)][globalIndex].toJS === 'function'
? this.props.totalRowObjects[parseInt(tableID)][globalIndex].toJS()
: this.props.totalRowObjects[parseInt(tableID)][globalIndex])
: (this.props.rowObjects.size > 0 || this.props.rowObjects.length > 0)
? (typeof this.props.rowObjects.toJS === 'function'
? this.props.rowObjects.get(index).toJS()
Expand Down Expand Up @@ -212,6 +213,7 @@ class SortableTable extends ImmutableComponent {
? <tr {...rowAttributes}
data-context-menu-disable={rowAttributes.onContextMenu ? true : undefined}
id={this.props.tableID}
data-global-index={i}
className={
(this.hasRowClassNames
? this.props.rowClassNames[i] + ' ' + rowAttributes.className
Expand Down

0 comments on commit 00f7026

Please sign in to comment.