mirror of
https://github.com/google/blockly.git
synced 2026-01-09 18:10:08 +01:00
fix: bad order of checks for setting flyout visibility (#5681)
* chore: fix redeclares in tests * fix: bad order of checks for setting flyout visibility
This commit is contained in:
@@ -968,7 +968,7 @@ Toolbox.prototype.selectItemByPosition = function(position) {
|
||||
* @protected
|
||||
*/
|
||||
Toolbox.prototype.updateFlyout_ = function(oldItem, newItem) {
|
||||
if ((oldItem === newItem && !newItem.isCollapsible()) || !newItem ||
|
||||
if (!newItem || (oldItem === newItem && !newItem.isCollapsible()) ||
|
||||
!newItem.getContents().length) {
|
||||
this.flyout_.hide();
|
||||
} else {
|
||||
|
||||
@@ -204,8 +204,8 @@ suite('InsertionMarkers', function() {
|
||||
});
|
||||
suite('Serialization', function() {
|
||||
setup(function() {
|
||||
this.assertXml = function(xml, expectXml) {
|
||||
Blockly.Xml.domToWorkspace(xml, this.workspace);
|
||||
this.assertXml = function(xmlIn, expectXml) {
|
||||
Blockly.Xml.domToWorkspace(xmlIn, this.workspace);
|
||||
let block = this.workspace.getBlockById('insertion');
|
||||
block.setInsertionMarker(true);
|
||||
let xml = Blockly.Xml.workspaceToDom(this.workspace);
|
||||
|
||||
@@ -407,7 +407,6 @@ suite('Toolbox', function() {
|
||||
|
||||
function testHideFlyout(toolbox, oldItem, newItem) {
|
||||
let updateFlyoutStub = sinon.stub(toolbox.flyout_, 'hide');
|
||||
const newItem = getNonCollapsibleItem(toolbox);
|
||||
toolbox.updateFlyout_(oldItem, newItem);
|
||||
sinon.assert.called(updateFlyoutStub);
|
||||
}
|
||||
@@ -419,6 +418,10 @@ suite('Toolbox', function() {
|
||||
test('No new item -> Should close flyout', function() {
|
||||
testHideFlyout(this.toolbox, null, null);
|
||||
});
|
||||
test('Old item but no new item -> Should close flyout', function() {
|
||||
let oldItem = getNonCollapsibleItem(this.toolbox);
|
||||
testHideFlyout(this.toolbox, oldItem, null);
|
||||
});
|
||||
test('Select collapsible item -> Should close flyout', function() {
|
||||
let newItem = getCollapsibleItem(this.toolbox);
|
||||
testHideFlyout(this.toolbox, null, newItem);
|
||||
|
||||
Reference in New Issue
Block a user