0

power-bookmarks-side-panel's non functional options fixed

power-bookmarks-side-panel's  "Add Current tab" and "+ New Folder" option
was not functional when new folder was added through Edit menu while
editing a bookmark.

Description:

Two folder was getting created,
one with onBookmarksEdited_ funtion which is
working fine.
Second folder was getting created with line 244 in src/chrome/browser/resources/side_panel/bookmarks/power_bookmarks_edit_dialog.ts
This is adding bookmark with wrong id in the tree.


Fixed the bug:
Removing the extra folder created from edit-menu.


Bug-Id: b/40071080
Change-Id: Ia6575302026c5a1f78db7715c5ab50102e5cbd41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5334683
Reviewed-by: Alison Gale <agale@chromium.org>
Reviewed-by: Emily Shack <emshack@chromium.org>
Commit-Queue: Alison Gale <agale@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1284121}
This commit is contained in:
Paras Awasthi
2024-04-08 21:51:28 +00:00
committed by Chromium LUCI CQ
parent 1258a22825
commit 84e1e55747
3 changed files with 12 additions and 1 deletions
AUTHORS
chrome/browser/resources/side_panel/bookmarks

@ -1042,6 +1042,7 @@ Owen Yuwono <owenyuwono@gmail.com>
Palash Verma <palashverma47@gmail.com>
Pan Deng <pan.deng@intel.com>
Parag Radke <nrqv63@motorola.com>
Paras Awasthi <awasthiparas6@gmail.com>
Paritosh Kumar <paritosh.in@samsung.com>
Pasquale Riello <pas.riello@gmail.com>
Patrasciuc Sorin Cristian <cristian.patrasciuc@gmail.com>

@ -18,6 +18,8 @@ import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bu
import {getTemplate} from './power_bookmarks_edit_dialog.html.js';
import {getFolderDescendants} from './power_bookmarks_service.js';
export const TEMP_FOLDER_ID_PREFIX = 'tmp_new_folder_';
export interface PowerBookmarksEditDialogElement {
$: {
dialog: CrDialogElement,
@ -230,7 +232,7 @@ export class PowerBookmarksEditDialogElement extends PolymerElement {
const parentId =
parent ? parent.id : loadTimeData.getString('otherBookmarksId');
const newFolder: chrome.bookmarks.BookmarkTreeNode = {
id: 'tmp_new_folder_' + this.newFolders_.length,
id: TEMP_FOLDER_ID_PREFIX + this.newFolders_.length,
title: loadTimeData.getString('newFolderTitle'),
children: [],
parentId: parentId,

@ -52,6 +52,7 @@ import {BookmarksApiProxyImpl} from './bookmarks_api_proxy.js';
import type {PowerBookmarksContextMenuElement} from './power_bookmarks_context_menu.js';
import {PowerBookmarksDragManager} from './power_bookmarks_drag_manager.js';
import type {PowerBookmarksEditDialogElement} from './power_bookmarks_edit_dialog.js';
import {TEMP_FOLDER_ID_PREFIX} from './power_bookmarks_edit_dialog.js';
import type {PowerBookmarksLabelsElement} from './power_bookmarks_labels.js';
import {getTemplate} from './power_bookmarks_list.html.js';
import type {Label} from './power_bookmarks_service.js';
@ -947,6 +948,13 @@ export class PowerBookmarksListElement extends PolymerElement {
if (folder.id === parentId) {
parentId = newFolder.id;
}
// Removing folders added in edit menu while editing a bookmark as they
// are made with TEMP_FOLDER_ID_PREFIX bookmark-id and are again created
// with correct id with createFolder method above
const parentFolder =
this.bookmarksService_.findBookmarkWithId(folder.parentId)!;
parentFolder.children = parentFolder.children?.filter(
child => !child.id.startsWith(TEMP_FOLDER_ID_PREFIX));
}
this.bookmarksApi_.editBookmarks(
event.detail.bookmarks.map(bookmark => bookmark.id), event.detail.name,