Skip to content

Commit

Permalink
fix: retain position when drag-and-dropping new bookmark
Browse files Browse the repository at this point in the history
When creating a new bookmark by drag-and-drop, and the "add to top" feature is not selected, retain the index if there is one.
  • Loading branch information
teddy-gustiaux committed Jan 25, 2021
1 parent da2e46a commit 28d6b85
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/_locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"message": "Neue Lesezeichen am Anfang des ausgewählten Ordners hinzufügen"
},
"options_ff_built_in_folder_top_help": {
"message": "Wenn deaktiviert, werden neue Lesezeichen am Ende des ausgewählten Ordners hinzugefügt."
"message": "If disabled, new bookmarks will be added to the bottom of the selected folder or where dragged-and-dropped"
},
"options_ff_built_in_folder_all_tabs_note": {
"message": "Folgende Einstellungen gelten nur, wenn Sie mehrere ausgewählte Tabs gleichzeitig mit einem Lesezeichen versehen oder die Funktion \"Tabs als Lesezeichen hinzufügen...\" für alle geöffneten Tabs verwenden. Damit können Sie den Standard-Speicherort des neu erstellten Ordners, der je nach Funktion ein Lesezeichen für alle ausgewählten oder geöffneten Tab enthält, sowie die Position des Ordners an diesem Speicherort überschreiben."
Expand Down
2 changes: 1 addition & 1 deletion src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"message": "Add new bookmarks to the top of the selected folder"
},
"options_ff_built_in_folder_top_help": {
"message": "If disabled, new bookmarks will be added to the bottom of the selected folder"
"message": "If disabled, new bookmarks will be added to the bottom of the selected folder or where dragged-and-dropped"
},
"options_ff_built_in_folder_all_tabs_note": {
"message": "The settings below only apply when bookmarking multiple selected tabs at once or when using the \"Bookmark All Tabs...\" feature for all open tabs. It allows you to override the default location of the newly created folder, which contains itself one bookmark for each of the selected or open tabs (depending on the feature), as well as the position of the folder in this location."
Expand Down
2 changes: 1 addition & 1 deletion src/_locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"message": "Ajouter les nouveaux marque-pages en haut du dossier sélectionné"
},
"options_ff_built_in_folder_top_help": {
"message": "Si désactivé, les nouveaux marque-pages seront ajoutés en bas du dossier sélectionné"
"message": "Si désactivé, les nouveaux marque-pages seront ajoutés en bas du dossier sélectionné ou à la position du glisser-déposer"
},
"options_ff_built_in_folder_all_tabs_note": {
"message": "Les paramètres ci-dessous ne s’applique qu’aux fonctionnalités permettant de marquer les onglets sélectionnés ou de \"Marquer tous les onglets...\" ouverts de Firefox. Ils vous permettent de choisir le dossier (et la position) par défaut du dossier nouvellement créé, qui contient un marque-page pour chaque onglet sélectionné ou ouvert (suivant la fonctionnalité utilisée)."
Expand Down
2 changes: 1 addition & 1 deletion src/_locales/hu/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"message": "Új könyvjelzõk hozzáadása a kiválasztott mappa tetejéhez"
},
"options_ff_built_in_folder_top_help": {
"message": "Ha tiltott, akkor az új könyvjelzõk a kiválasztott mappa aljára kerülnek"
"message": "If disabled, new bookmarks will be added to the bottom of the selected folder or where dragged-and-dropped"
},
"options_ff_built_in_folder_all_tabs_note": {
"message": "The settings below only apply when bookmarking multiple selected tabs at once or when using the \"Bookmark All Tabs...\" feature for all open tabs. It allows you to override the default location of the newly created folder, which contains itself one bookmark for each of the selected or open tabs (depending on the feature), as well as the position of the folder in this location."
Expand Down
2 changes: 1 addition & 1 deletion src/_locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"message": "Добавлять новые закладки на первую позицию (внутри выбранной папки)"
},
"options_ff_built_in_folder_top_help": {
"message": "Если эта настройка отключена, новые закладки будут добавляться после уже имеющихся элементов (в выбранной папке)"
"message": "If disabled, new bookmarks will be added to the bottom of the selected folder or where dragged-and-dropped"
},
"options_ff_built_in_folder_all_tabs_note": {
"message": "The settings below only apply when bookmarking multiple selected tabs at once or when using the \"Bookmark All Tabs...\" feature for all open tabs. It allows you to override the default location of the newly created folder, which contains itself one bookmark for each of the selected or open tabs (depending on the feature), as well as the position of the folder in this location."
Expand Down
10 changes: 7 additions & 3 deletions src/background/bookmarking/BuiltinBookmarking.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BuiltinBookmarking {
this._options = options;
}

_createMovingPropertiesForBookmark() {
_createMovingPropertiesForBookmark(bookmarkInfo) {
const bookmarkTreeNode = {};
if (this._options.isBuiltinFolderSet()) {
if (this._options.isBuiltinFolderLastUsed()) {
Expand All @@ -20,7 +20,11 @@ class BuiltinBookmarking {
bookmarkTreeNode.parentId = this._options.getBuiltinFolder();
}
}
if (this._options.addBuiltinBookmarksOnTop()) bookmarkTreeNode.index = 0;
if (this._options.addBuiltinBookmarksOnTop()) {
bookmarkTreeNode.index = 0;
} else {
if (bookmarkInfo.index) bookmarkTreeNode.index = bookmarkInfo.index;
}
return bookmarkTreeNode;
}

Expand Down Expand Up @@ -60,7 +64,7 @@ class BuiltinBookmarking {
let bookmarkTreeNode;
if (Utils.bookmarkIsWebPage(bookmarkInfo)) {
if (await Utils.bookmarkIsPartOfAllTabsFolder(bookmarkInfo)) return;
bookmarkTreeNode = this._createMovingPropertiesForBookmark();
bookmarkTreeNode = this._createMovingPropertiesForBookmark(bookmarkInfo);
} else if (Utils.bookmarkIsFolder(bookmarkInfo)) {
if (!Utils.bookmarkIsAllTabsSystemCreatedFolder(bookmarkInfo)) return;
bookmarkTreeNode = this._createMovingPropertiesForAllTabsFolder();
Expand Down

0 comments on commit 28d6b85

Please sign in to comment.