* Makes sure that when the block is collapsed, it is rendered correctly * for that state.
()
| 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. |
no test coverage detected