Skip to content

Commit 1c5b031

Browse files
authored
fix(field-bitmap): revert separate keys for revert and commit (#2760)
* fix(field-bitmap): revert separate keys for revert and commit * chore: revert private method signature changes
1 parent 6342e38 commit 1c5b031

3 files changed

Lines changed: 5 additions & 28 deletions

File tree

plugins/field-bitmap/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "@blockly/field-bitmap",
33
"version": "13.2.0",
4-
"private": true,
54
"description": "A field that lets users input a pixel grid with their mouse.",
65
"scripts": {
76
"audit:fix": "blockly-scripts auditFix",

plugins/field-bitmap/src/field-bitmap.ts

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ export class FieldBitmap extends Blockly.Field<number[][]> {
338338
this.bindEvent(dropdownEditor, 'pointerleave', this.onPointerEnd);
339339
this.bindEvent(dropdownEditor, 'pointerdown', this.onPointerStart);
340340
this.bindEvent(dropdownEditor, 'pointercancel', this.onPointerEnd);
341-
this.bindEvent(dropdownEditor, 'keydown', this.onEditorKeyDown);
342341
// Stop the browser from handling touch events and cancelling the event.
343342
this.bindEvent(dropdownEditor, 'touchmove', (e: Event) => {
344343
e.preventDefault();
@@ -424,26 +423,6 @@ export class FieldBitmap extends Blockly.Field<number[][]> {
424423
return grid;
425424
}
426425

427-
/**
428-
* Handles editor-level keyboard shortcuts.
429-
* Ctrl/Cmd+Enter commits and closes; Escape reverts and closes.
430-
*
431-
* @param e The keydown event.
432-
*/
433-
private onEditorKeyDown(e: KeyboardEvent) {
434-
const isEscape = e.key === 'Escape';
435-
const isCommit = e.key === 'Enter' && (e.ctrlKey || e.metaKey);
436-
if (!isEscape && !isCommit) return;
437-
438-
if (isEscape && this.initialValue !== null) {
439-
this.setValue(this.initialValue, false);
440-
}
441-
Blockly.DropDownDiv.hideIfOwner(this);
442-
Blockly.getFocusManager().focusNode(this);
443-
e.preventDefault();
444-
e.stopPropagation();
445-
}
446-
447426
/**
448427
* Handles keyboard navigation and activation inside the pixel grid.
449428
*
@@ -737,7 +716,6 @@ export class FieldBitmap extends Blockly.Field<number[][]> {
737716
this.focusedPixelIndex = -1;
738717
this.pointerIsDown = false;
739718
this.valToPaintWith = undefined;
740-
// Set this.initialValue back to null.
741719
this.initialValue = null;
742720

743721
Blockly.DropDownDiv.getContentDiv().classList.remove(
@@ -843,10 +821,11 @@ export class FieldBitmap extends Blockly.Field<number[][]> {
843821
* Resets pointer state (e.g. After either a pointerup event or if the
844822
* gesture is canceled).
845823
*
846-
* @param e The pointer event that ended the gesture.
824+
* @param e The pointer event that ended the gesture, when available.
847825
*/
848-
private onPointerEnd(e: PointerEvent) {
826+
private onPointerEnd(e?: PointerEvent) {
849827
if (
828+
e &&
850829
e.currentTarget instanceof HTMLElement &&
851830
e.currentTarget.hasPointerCapture?.(e.pointerId)
852831
) {
@@ -938,10 +917,10 @@ export class FieldBitmap extends Blockly.Field<number[][]> {
938917
* @param eventName Name of the event to bind.
939918
* @param callback Function to be called on specified event.
940919
*/
941-
private bindEvent<E extends Event>(
920+
private bindEvent(
942921
element: HTMLElement,
943922
eventName: string,
944-
callback: (e: E) => void,
923+
callback: (e: PointerEvent) => void,
945924
) {
946925
this.boundEvents.push(
947926
Blockly.browserEvents.bind(element, eventName, this, callback),

plugins/field-colour-hsv-sliders/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "@blockly/field-colour-hsv-sliders",
33
"version": "13.2.0",
4-
"private": true,
54
"description": "A Blockly colour field using HSV sliders.",
65
"scripts": {
76
"audit:fix": "blockly-scripts auditFix",

0 commit comments

Comments
 (0)