Skip to content

Commit

Permalink
A few blockly tutorial fixes (#10384)
Browse files Browse the repository at this point in the history
* fix class validation for numberdropdown with no min/max

* don't cache flyot when tutorial has block config

* fix tileset field in tutorial hint
  • Loading branch information
riknoll authored Feb 13, 2025
1 parent 211c932 commit 4c5f478
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pxtblocks/fields/field_numberdropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ class BaseFieldNumberDropdown extends BaseFieldTextDropdown {
return null;
}
// Get the value in range.
n = Math.min(Math.max(n, this.min_), this.max_);
if (this.min_ !== undefined) {
n = Math.max(n, this.min_);
}
if (this.max_ !== undefined) {
n = Math.min(n, this.max_);
}
// Round to nearest multiple of precision.
if (this.precision_ && isFinite(n)) {
n = Math.round(n / this.precision_) * this.precision_;
Expand Down
3 changes: 3 additions & 0 deletions pxtblocks/fields/field_tileset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ export class FieldTileset extends FieldImages implements FieldCustom {
else if (newValue.startsWith(pxt.sprite.TILE_NAMESPACE)) {
tile = project.lookupAsset(pxt.AssetType.Tile, newValue.trim());
}
else {
tile = project.lookupAssetByName(pxt.AssetType.Tile, newValue.trim());
}

if (tile) {
this.localTile = tile;
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/blocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,7 @@ export class Editor extends toolboxeditor.ToolboxEditor {
// Cache blocks xml list for later
this.flyoutBlockXmlCache[cacheKey] = this.flyoutXmlList;
}
this.showFlyoutInternal_(this.flyoutXmlList, cacheKey);
this.showFlyoutInternal_(this.flyoutXmlList, cachable && cacheKey);
}
}

Expand Down

0 comments on commit 4c5f478

Please sign in to comment.