Repository navigation
fix: only hide WidgetDiv when its owner is in the given workspace #10633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -441,13 +441,22 @@ suite('Mirroring events', function () { | |
| '<!DOCTYPE html><div id="blocklyDiv"></div>', | ||
| ); | ||
| global.SVGElement = window.SVGElement; | ||
| global.FocusEvent = window.FocusEvent; | ||
| window.HTMLCanvasElement.prototype.getContext = () => ({ | ||
| measureText: () => ({ | ||
| width: '', | ||
| fontBoundingBoxAscent: 12, | ||
| fontBoundingBoxDescent: 4, | ||
| }), | ||
| }); | ||
| // jsdom does not implement CSS.escape, which keyboard navigation uses to | ||
| // look up elements by ID. | ||
| global.CSS = { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basically doing a tab on a keyboard, tries to use the |
||
| escape: (id) => | ||
| id.replace(/^\d|[^\w-]/g, (char, offset) => | ||
| offset === 0 && /\d/.test(char) ? `\\3${char} ` : `\\${char}`, | ||
| ), | ||
| }; | ||
| this.clock = sinon.useFakeTimers(); | ||
| window.requestAnimationFrame = (callback) => setTimeout(callback, 0); | ||
| window.cancelAnimationFrame = (id) => clearTimeout(id); | ||
|
|
@@ -463,6 +472,7 @@ suite('Mirroring events', function () { | |
| this.workspace.dispose(); | ||
| this.clock.runAll(); | ||
| sinon.restore(); | ||
| delete global.CSS; | ||
| this.jsdomCleanup(); | ||
| }); | ||
|
|
||
|
|
@@ -481,6 +491,37 @@ suite('Mirroring events', function () { | |
| 'Minimap block should show the renamed variable', | ||
| ); | ||
| }); | ||
|
|
||
| test('Tabbing between edited fields keeps the next editor open', async function () { | ||
| const block = Blockly.serialization.blocks.append( | ||
| { | ||
| type: 'controls_for', | ||
| inputs: { | ||
| FROM: {shadow: {type: 'math_number', fields: {NUM: 1}}}, | ||
| TO: {shadow: {type: 'math_number', fields: {NUM: 10}}}, | ||
| }, | ||
| }, | ||
| this.workspace, | ||
| ); | ||
| await this.clock.runAllAsync(); | ||
| const fromField = block.getInputTargetBlock('FROM').getField('NUM'); | ||
| const toField = block.getInputTargetBlock('TO').getField('NUM'); | ||
|
|
||
| fromField.showEditor(); | ||
| fromField.setValue(2); | ||
| document | ||
| .querySelector('.blocklyHtmlInput') | ||
| .dispatchEvent( | ||
| new window.KeyboardEvent('keydown', {key: 'Tab', bubbles: true}), | ||
| ); | ||
| // Let the minimap mirror the change and zoom to fit. | ||
| await this.clock.runAllAsync(); | ||
|
|
||
| assert.isTrue( | ||
| toField.isBeingEdited_, | ||
| 'The editor opened by Tab should stay open after the minimap updates', | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| suite('Keyboard navigation', function () { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check was always true first time as the
currentWorkspacewasworkspaceonly because of the assignment on line 262. Thus an ownership check would always return true