Commit ad50dc9e authored by Alex Danilo's avatar Alex Danilo Committed by Commit Bot

Stop spurious feedback panels being displayed

Panel items can be created and attached to a a display panel by
calling createPanelItem() followed by attachPanelItem() and they
can be removed by calling removePanelItem().

Change the API surface for attaching panel items to ignore panel
items that have already been removed using removePanelItem().

Bug: 1006124
Tests: Updated browser_tests --gtest_filter="FileManagerJsTest.FilesDisplayPanel"
Change-Id: Id7dce8496f4a5cf2090b9071404bd45b5033ae07
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1819078Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Alex Danilo <adanilo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#698833}
parent 2ef84150
...@@ -61,12 +61,35 @@ async function testFilesDisplayPanel(done) { ...@@ -61,12 +61,35 @@ async function testFilesDisplayPanel(done) {
assertTrue(displayPanel.findPanelItemById('testpanel1') === null); assertTrue(displayPanel.findPanelItemById('testpanel1') === null);
// Add another panel item and confirm the expanded state persists by // Add another panel item and confirm the expanded state persists by
// checking the pnel container is not hidden and there is a summary panel. // checking the panel container is not hidden and there is a summary panel.
progressPanel = displayPanel.addPanelItem('testpanel1'); progressPanel = displayPanel.addPanelItem('testpanel1');
progressPanel.panelType = progressPanel.panelTypeProgress; progressPanel.panelType = progressPanel.panelTypeProgress;
assertFalse(panelContainer.hasAttribute('hidden')); assertFalse(panelContainer.hasAttribute('hidden'));
summaryPanelItem = summaryContainer.querySelector('xf-panel-item'); summaryPanelItem = summaryContainer.querySelector('xf-panel-item');
assertTrue(summaryPanelItem.panelType === summaryPanelItem.panelTypeSummary); assertTrue(summaryPanelItem.panelType === summaryPanelItem.panelTypeSummary);
// Test create/attach/remove sequences.
// Create a progress panel item.
progressPanel = displayPanel.createPanelItem('testpanel2');
progressPanel.panelType = progressPanel.panelTypeProgress;
// Attach the panel to it's host display panel.
displayPanel.attachPanelItem(progressPanel);
// Verify the panel is attached to the document.
assertTrue(!!progressPanel.parentNode);
// Remove the panel item.
displayPanel.removePanelItem(progressPanel);
// Verify the panel item is not attached to the document.
assertTrue(progressPanel.parentNode === null);
// Create a progress panel item.
progressPanel = displayPanel.createPanelItem('testpanel3');
progressPanel.panelType = progressPanel.panelTypeProgress;
// Remove the panel item.
displayPanel.removePanelItem(progressPanel);
// Try to attach the removed panel to it's host display panel.
displayPanel.attachPanelItem(progressPanel);
// Verify the panel is not attached to the document.
assertTrue(progressPanel.parentNode === null);
done(); done();
} }
...@@ -327,6 +327,11 @@ class DisplayPanel extends HTMLElement { ...@@ -327,6 +327,11 @@ class DisplayPanel extends HTMLElement {
*/ */
attachPanelItem(panel) { attachPanelItem(panel) {
const displayPanel = panel.parent; const displayPanel = panel.parent;
// Only attach the panel if it hasn't been removed.
const index = displayPanel.items_.indexOf(panel);
if (index === -1) {
return;
}
displayPanel.panels_.appendChild(panel); displayPanel.panels_.appendChild(panel);
displayPanel.updateSummaryPanel(); displayPanel.updateSummaryPanel();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment