Skip to content

Commit e6185c5

Browse files
authored
fix rendering for getter/setter blocks in eval tool (microsoft#11054)
1 parent f012997 commit e6185c5

3 files changed

Lines changed: 24 additions & 14 deletions

File tree

‎teachertool/src/components/styling/BlockPickerModal.module.scss‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,30 @@
99
overflow-x: hidden;
1010
overflow-y: auto;
1111
padding: 0;
12-
12+
1313
.bottom-border {
1414
border-bottom: 2px solid var(--pxt-target-background1-hover);
1515
}
16-
16+
1717
.loading-container {
1818
display: flex;
1919
flex-direction: column;
2020
justify-content: center;
2121
align-items: center;
2222
height: 100%;
2323
width: 100%;
24-
24+
2525
div[class*="common-spinner"] {
2626
width: 5rem;
2727
height: 5rem;
2828
margin: 1rem;
2929
}
3030
}
31-
31+
3232
.category-container {
3333
border-left: 1rem solid var(--category-color);
3434
color: var(--category-color);
35-
35+
3636
.category-button {
3737
width: 100%;
3838
padding: 0.5rem;
@@ -42,22 +42,22 @@
4242
border-radius: 0;
4343
color: var(--category-color);
4444
}
45-
45+
4646
.category-block-list {
4747
width: 100%;
4848
display: flex;
4949
flex-direction: column;
5050
align-items: flex-start;
51-
51+
5252
transition: max-height 0.2s ease-out;
5353
&.collapsed {
5454
max-height: 0;
5555
display:none;
5656
}
5757
&.expanded {
58-
max-height: 100rem; /* larger that it should ever get */
58+
max-height: 200rem; /* larger that it should ever get */
5959
}
60-
60+
6161
.block-button {
6262
width: 100%;
6363
align-content: start;

‎teachertool/src/transforms/loadBlockImagesAsync.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,16 @@ async function loadBlockImageAsync(block: pxt.editor.ToolboxBlockDefinition) {
2626
export async function loadBlockImagesAsync(category: pxt.editor.ToolboxCategoryDefinition) {
2727
return category.blocks
2828
? pxt.Util.promisePoolAsync(
29-
4,
30-
category.blocks,
31-
async (block: pxt.editor.ToolboxBlockDefinition) => await loadBlockImageAsync(block)
32-
)
29+
4,
30+
category.blocks,
31+
async (block: pxt.editor.ToolboxBlockDefinition) => {
32+
try {
33+
await loadBlockImageAsync(block);
34+
}
35+
catch (e) {
36+
console.warn(`Failed to load image for block ${block.name}: ${e}`);
37+
}
38+
}
39+
)
3340
: Promise.resolve();
3441
}

‎webapp/src/app.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4298,7 +4298,10 @@ export class ProjectView
42984298
async renderByBlockIdAsync(req: pxt.editor.EditorMessageRenderByBlockIdRequest): Promise<pxt.editor.EditorMessageRenderByBlockIdResponse> {
42994299
const blocksInfo = await compiler.getBlocksAsync();
43004300
const blockInfo = blocksInfo.blocksById[req.blockId];
4301-
const symbolInfo: pxtc.SymbolInfo = blocksInfo.apis.byQName[blockInfo.qName];
4301+
let symbolInfo: pxtc.SymbolInfo = blocksInfo.apis.byQName[blockInfo.qName];
4302+
if (!symbolInfo) {
4303+
symbolInfo = pxtblockly.blockSymbol(blockInfo.attributes.blockId)
4304+
}
43024305
const compileInfo: pxt.blocks.BlockCompileInfo = pxt.blocks.compileInfo(symbolInfo);
43034306
const xml = pxtblockly.createToolboxBlock(blocksInfo, symbolInfo, compileInfo, false, 3);
43044307
return this.renderXmlInner(xml.outerHTML, req.snippetMode, req.layout);

0 commit comments

Comments
 (0)