Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Fix drag-n-drop for topSites grid
Browse files Browse the repository at this point in the history
Fixes #5336

Auditors: @bsclifton

Test Plan:

* Copy/paste this file to session-store-1: https://raw.githubusercontent.com/cezaraugusto/brave-json/master/newtab-3-rows.json
* Check that now we have 18 tiles on our grid
* Randomly drag tiles and check that it can be dropped on any position
* Open a new new tab and ensure items keep their previous indexes
  • Loading branch information
cezaraugusto authored and bsclifton committed Nov 2, 2016
1 parent 9e74d8e commit 6cb8b2a
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions js/about/newtab.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,11 @@ class NewTabPage extends React.Component {

// We need to know which sites are pinned first, so we can skip them while populating
gridSites = gridSites.push.apply(pinnedTopSites, gridSites)

for (let i = 0; i < gridSites.size; i++) {
// skip pinnedTopSites while populating
if (!this.isPinned(i)) {
gridSites = gridSites.set(i, sites.first())
sites = sites.shift()
}
}
gridSites = gridSites.map((item, i) => item == null ? sites.get(i) : item)

// Remove from grid all ignored sites
gridSites = gridSites.filter((site) => ignoredTopSites.indexOf(site) === -1)

// Filter duplicated and remove null
gridSites = gridSites.toSet().toList()
gridSites = gridSites.filter(site => site != null)

return gridSites
Expand Down

0 comments on commit 6cb8b2a

Please sign in to comment.