MCPcopy
hub / github.com/RaspberryPiFoundation/blockly / updateCollapsed

Method updateCollapsed

packages/blockly/core/block_svg.ts:569–611  ·  view source on GitHub ↗

* Makes sure that when the block is collapsed, it is rendered correctly * for that state.

()

Source from the content-addressed store, hash-verified

567 * for that state.
568 */
569 private updateCollapsed() {
570 const collapsed = this.isCollapsed();
571 const collapsedInputName = constants.COLLAPSED_INPUT_NAME;
572 const collapsedFieldName = constants.COLLAPSED_FIELD_NAME;
573
574 for (let i = 0, input; (input = this.inputList[i]); i++) {
575 if (input.name !== collapsedInputName) {
576 input.setVisible(!collapsed);
577 }
578 }
579
580 for (const icon of this.getIcons()) {
581 icon.updateCollapsed();
582 }
583
584 if (!collapsed) {
585 this.updateDisabled();
586 this.removeInput(collapsedInputName);
587 dom.removeClass(this.svgGroup, 'blocklyCollapsed');
588 this.setWarningText(null, BlockSvg.COLLAPSED_WARNING_ID);
589 return;
590 }
591
592 dom.addClass(this.svgGroup, 'blocklyCollapsed');
593 if (this.childHasWarning()) {
594 this.setWarningText(
595 Msg['COLLAPSED_WARNINGS_WARNING'],
596 BlockSvg.COLLAPSED_WARNING_ID,
597 );
598 }
599
600 const text = this.toString(internalConstants.COLLAPSE_CHARS);
601 const field = this.getField(collapsedFieldName);
602 if (field) {
603 field.setValue(text);
604 return;
605 }
606 const input =
607 this.getInput(collapsedInputName) ||
608 this.appendDummyInput(collapsedInputName);
609 input.appendField(new FieldLabel(text), collapsedFieldName);
610 this.recomputeAriaContext();
611 }
612
613 /**
614 * Handle a pointerdown on an SVG block.

Callers 2

setCollapsedMethod · 0.95
renderEfficientlyMethod · 0.95

Calls 15

updateDisabledMethod · 0.95
removeInputMethod · 0.95
setWarningTextMethod · 0.95
childHasWarningMethod · 0.95
recomputeAriaContextMethod · 0.95
getIconsMethod · 0.80
getFieldMethod · 0.80
getInputMethod · 0.80
appendDummyInputMethod · 0.80
appendFieldMethod · 0.80
setVisibleMethod · 0.65
updateCollapsedMethod · 0.65

Tested by

no test coverage detected