fix: collapsing blocks with children with icons (#7111)

* fix: collapsing blocks with icons

* chore: add tests for hiding icons of collapsed children
This commit is contained in:
Beka Westberg
2023-05-22 13:53:34 -07:00
committed by GitHub
parent d90d00570f
commit 6e3d052100
6 changed files with 138 additions and 133 deletions

View File

@@ -6,7 +6,7 @@
export interface IHasBubble {
/** @return True if the bubble is currently open, false otherwise. */
isBubbleVisible(): boolean;
bubbleIsVisible(): boolean;
/** Sets whether the bubble is open or not. */
setBubbleVisible(visible: boolean): void;
@@ -15,6 +15,6 @@ export interface IHasBubble {
/** Type guard that checks whether the given object is a IHasBubble. */
export function hasBubble(obj: any): obj is IHasBubble {
return (
obj.isBubbleVisible !== undefined && obj.setBubbleVisible !== undefined
obj.bubbleIsVisible !== undefined && obj.setBubbleVisible !== undefined
);
}

View File

@@ -20,6 +20,7 @@ import {Connection} from './connection.js';
import type {ConnectionDB} from './connection_db.js';
import {ConnectionType} from './connection_type.js';
import * as eventUtils from './events/utils.js';
import {hasBubble} from './interfaces/i_has_bubble.js';
import * as internalConstants from './internal_constants.js';
import {Coordinate} from './utils/coordinate.js';
import * as dom from './utils/dom.js';
@@ -428,9 +429,13 @@ export class RenderedConnection extends Connection {
connections[j].setTracking(false);
}
// Close all bubbles of all children.
const icons = block.getIcons();
for (let j = 0; j < icons.length; j++) {
icons[j].setVisible(false);
for (const icon of block.getIcons()) {
if (hasBubble(icon)) {
icon.setBubbleVisible(false);
} else if (icon.setVisible) {
// TODO (#7042): Remove old icon handling code.
icon.setVisible(false);
}
}
}
}

View File

@@ -41,7 +41,7 @@ export class Icon extends Measurable {
// TODO(#7042): Remove references to old icon API.
this.isVisible =
(icon.isVisible && icon.isVisible()) ||
(hasBubble(icon) && icon.isBubbleVisible());
(hasBubble(icon) && icon.bubbleIsVisible());
this.type |= Types.ICON;
const size =