Skip to content

Commit abeac11

Browse files
authored
Merge pull request #34 from cbcode1/mobile-fixes
Release 1.7.3
2 parents 463c545 + 30d59cd commit abeac11

7 files changed

Lines changed: 8923 additions & 8835 deletions

File tree

API.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Block Based Code (`@webwriter/block-based-code@1.7.2`)
2-
[License: MIT](LICENSE) | Version: 1.7.2
1+
# Block Based Code (`@webwriter/block-based-code@1.7.3`)
2+
[License: MIT](LICENSE) | Version: 1.7.3
33

44
Write block-based code (e.g. Scratch) and run it.
55

components/editor/editor.component.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export class Editor extends LitElementWw {
3838
@query("#alert")
3939
private accessor alertDialog!: SlDialog;
4040

41+
private dialogOpenedAt = 0;
42+
4143
public static get scopedElements(): Record<string, typeof LitElement> {
4244
return {
4345
"webwriter-blocks-toolbar": Toolbar,
@@ -78,7 +80,7 @@ export class Editor extends LitElementWw {
7880

7981
public render(): TemplateResult {
8082
return html`
81-
<sl-dialog id="prompt" no-header>
83+
<sl-dialog id="prompt" no-header @sl-request-close=${this.handleDialogRequestClose}>
8284
<span></span>
8385
<sl-input autofocus placeholder=""></sl-input>
8486
<sl-button slot="footer" @click="${() => this.promptDialog.hide()}">Cancel</sl-button>
@@ -143,9 +145,18 @@ export class Editor extends LitElementWw {
143145
this.promptDialog.hide().catch();
144146
});
145147
button.parentNode.replaceChild(clonedButton, button);
148+
this.dialogOpenedAt = Date.now();
146149
this.promptDialog.show().catch();
147150
}
148151

152+
private handleDialogRequestClose(event: CustomEvent): void {
153+
// Prevent dialog from closing by the same event that opened it
154+
// (affected change value pop-up on mobile devices)
155+
if (event.detail.source === "overlay" && Date.now() - this.dialogOpenedAt < 100) {
156+
event.preventDefault();
157+
}
158+
}
159+
149160
private handleConfirm(message: string, callback: (confirmed: boolean) => void): void {
150161
Logger.log(this, message, callback);
151162
const titleSpan = this.confirmDialog.querySelector("span");

components/editor/editor.styles.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export const styles = css`
3030
background-color: var(--sl-color-neutral-0);
3131
border-right: 1px solid var(--sl-color-gray-300);
3232
33-
overflow-y: visible;
33+
overflow-y: auto;
34+
overflow-x: hidden;
3435
}
3536
3637
.blocklyTreeRow {

components/stage/stage.component.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ export class Stage extends LitElementWw {
233233
</webwriter-blocks-toolbar-button>
234234
</div>
235235
</webwriter-blocks-toolbar>
236-
<sl-tab-group placement="bottom">
236+
<sl-tab-group placement="bottom" @sl-tab-show=${this.handleTabShow}>
237237
<sl-tab slot="nav" panel="stage" active>${msg(`OPTIONS.STAGE_TYPES.${this.stageType.toUpperCase() as Uppercase<StageType>}`)}
238238
</sl-tab>
239239
<sl-tab slot="nav" panel="code">${msg("OPTIONS.STAGE_TYPES.CODE")}</sl-tab>
@@ -300,6 +300,17 @@ export class Stage extends LitElementWw {
300300
this.stageApplication.resize();
301301
}
302302

303+
/**
304+
* Handles the tab show event.
305+
* Resizes the stage when its tab is shown to ensure it is visible if the width has changed.
306+
* @private
307+
*/
308+
private handleTabShow(event: CustomEvent): void {
309+
if (event.detail.name === "stage") {
310+
requestAnimationFrame(() => this.stageApplication.resize());
311+
}
312+
}
313+
303314
/**
304315
* Handles the VM options click event.
305316
* @private

components/stage/stage.styles.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,19 @@ export const styles = css`
4141
}
4242
4343
sl-tab-group {
44-
height: 100%;
44+
flex: 1;
45+
min-height: 0;
4546
}
4647
4748
sl-tab-group::part(base) {
4849
height: 100%;
4950
}
5051
5152
sl-tab-group::part(body) {
52-
height: 100%;
53+
flex: 1;
54+
min-height: 0;
5355
position: relative;
56+
overflow: hidden;
5457
}
5558
5659
sl-tab::part(base) {

0 commit comments

Comments
 (0)