Commit Graph

4770 Commits

Author SHA1 Message Date
Aaron Dodson
eb4288219e fix: Fix bug that prevented redoing adding empty block comments (#9568)
* fix: Fix bug that prevented redoing adding empty block comments

* test: Add tests for undoing/redoing adding comments

* test: Add tests for un/redoing adding non-empty comments
2026-01-13 14:52:19 -08:00
Aaron Dodson
43ea4161c0 fix: Don't select shadow blocks on click (#9538)
* fix: Don't select shadow blocks on click

* test: Verify that clicked shadow blocks do not become selected

* chore: Run formatter
2026-01-13 14:23:08 -08:00
joey
a4d97c2f18 fix: collapsed warning propagation across siblings (#9566) (#9567) 2026-01-13 08:26:45 -08:00
Aaron Dodson
c79273a351 fix: Modernize audio playback (#9560)
* fix: Modernize audio playback

* fix: Fix loading on headless/Node
2026-01-13 08:05:51 -08:00
Aaron Dodson
52d935c815 fix: Fix bug that prevented deleting a variable referenced by two connected blocks (#9563)
* fix: Fix bug that prevented deleting a variable referenced by two connected blocks

* fix: Remove inadvertent .only
2026-01-12 15:57:00 -08:00
Aaron Dodson
9fc05dfe47 fix: Remove more instances of AnyDuringMigration (#9562)
* fix: Remove more instances of `AnyDuringMigration`

* chore: Fix lint
2026-01-12 11:23:18 -08:00
Aaron Dodson
25c6187d88 refactor: Make preconditionFn part of all context menu items (#9558)
* refactor: Make preconditionFn part of all context menu items

* test: Verify separator menu item behavior with precondition functions
2026-01-09 13:59:03 -08:00
Aaron Dodson
d331336e66 fix: Display dragged comments and bubbles atop the toolbox (#9552)
* fix: Display dragged comments and bubbles atop the toolbox

* test: Add tests for drag layer behavior
2026-01-08 08:16:41 -08:00
Aaron Dodson
93056bc8ad fix: Fix bug that prevented the first block change event in a flyout from being dispatched (#9539)
* fix: Fix bug that prevented the first block change event in a flyout from being dispatched

* chore: Add test for flyout event listeners
2025-12-23 10:19:28 -08:00
Aaron Dodson
b0dc1de0f9 fix: Don't open the toolbox when clicking beneath the categories (#9535)
* fix: Don't open the toolbox when clicking beneath the categories

* chore: Add docstring

* chore: Add test

* chore: Add comment clarifying selection logic
2025-12-23 09:37:03 -08:00
Aaron Dodson
f9fb226846 fix: Disable undoing events generated from flyout layout (#9533) 2025-12-22 13:10:57 -08:00
Simon Shiki
da5e8e68e3 fix: enforce placeholder usage for workspace comment (#9463)
* fix: enforce placeholder usage for workspace comment

Signed-off-by: SimonShiki <sinangentoo@gmail.com>

* fix: lint

Signed-off-by: SimonShiki <sinangentoo@gmail.com>

---------

Signed-off-by: SimonShiki <sinangentoo@gmail.com>
2025-12-05 09:19:52 -08:00
Robert Knight
8a226d8737 fix: navigation in dropdown menu with a separator (#9474) 2025-12-04 12:37:44 -08:00
Aaron Dodson
098a3aaffb fix: Add support for icons to getSourceBlockFromNode() (#9438) 2025-10-27 09:39:52 -07:00
Maribeth Moffatt
059cd249d2 feat: make FlyoutButton.callbackKey public (#9381) 2025-09-23 13:42:50 -07:00
Maribeth Moffatt
139fa2b3f2 fix: handle pointercancel only for drags (#9373) 2025-09-19 13:53:57 -07:00
Aaron Dodson
9b60088d4b fix: Fix bug that could caused variable map to be left in an inconsistent state. (#9339) 2025-09-02 12:39:16 -07:00
Aaron Dodson
47307a9e53 refactor: Make focusable elements responsible for scrolling themselves into bounds. (#9288)
* refactor: Make focusable elements responsible for scrolling themselves into bounds.

* chore: Add tests for scrolling focused elements into view.

* fix: Removed inadvertent `.only`.

* fix: Scroll parent block of connections into bounds on focus.
2025-08-28 11:28:40 -07:00
Aaron Dodson
fd0aaedb10 fix: Fix bug that could cause errant line when rendering. (#9333) 2025-08-28 10:06:52 -07:00
Aaron Dodson
3b498d1384 fix: Allow reregistering fields. (#9290) 2025-08-22 14:55:07 -07:00
Ennis Nian
802472486e fix: pointercancel event is not handled (#9250) 2025-08-21 13:59:09 -07:00
Aaron Dodson
c6730ab74f fix: Fix bug that caused inadvertent scrolling when the WidgetDiv was shown. (#9291)
* fix: Fix bug that caused inadvertent scrolling when the `WidgetDiv` was shown.

* chore: Add test to verify that displaying the context menu does not scroll the page.

* chore: Clarify comments.

* fix: Remove errant `.only`.

* chore: Add test to verify that actively focusing a node does not scroll the page.

* fix: Remove inadvertent `.only`.
2025-08-21 11:15:07 -07:00
Aaron Dodson
3e26b00038 fix: Correct the alignment of narrow text in input fields. (#9327)
* fix: Correct the alignment of narrow text in input fields.

* chore: Clarify purpose of first argument to positionTextElement_().
2025-08-21 11:05:43 -07:00
Aaron Dodson
5cc95e44e7 fix: Show the delete cursor when dragging a block by an editable field. (#9326) 2025-08-20 11:26:45 -07:00
Aaron Dodson
ac7619a622 chore: Fix documentation generation warnings. (#9325)
* chore: Replace @yields with @returns.

* fix: Update the ESLint config to not require @yields.

* chore: Move docs onto getters.
2025-08-19 14:56:59 -07:00
Aaron Dodson
405f7da280 fix: Fix positioning of pasted blocks and comments in RTL. (#9302)
* fix: Fix positioning of pasted blocks in RTL.

* fix: Clean up after temporarily making the workspace RTL.

* fix: Remove .only.

* fix: Fix positioning of pasted comments in RTL.

* fix: Fix positioning of text preview on collapsed comments in RTL.
2025-08-19 08:32:31 -07:00
Aaron Dodson
fb63360b9f refactor: Remove duplicated method from contextmenu_items.ts. (#9289) 2025-08-12 08:55:54 -07:00
Aaron Dodson
7d1d745416 fix: Drag immovable and shadow blocks along with their parent. (#9281) 2025-08-06 14:08:01 -07:00
Aaron Dodson
f9d0ec9d24 refactor: Associate comment bar buttons with the comment view. (#9278) 2025-08-06 14:04:12 -07:00
Aaron Dodson
af57a3eaa3 refactor: Make InsertionMarkerPreviewer's block serialization amenable to subclassing. (#9282) 2025-08-06 12:45:17 -07:00
Aaron Dodson
44e78b1456 feat: Add an option to copy subsequent blocks when getting copy data from a block. (#9279) 2025-08-05 11:17:10 -07:00
Aaron Dodson
88151fcadd fix: Display focused icons without transparency. (#9268) 2025-08-04 13:18:31 -07:00
Maribeth Moffatt
f24940e781 fix: dont add comments to full block fields (#9263)
* fix: dont add comments to full block fields

* chore: remove some nonnull assertions
2025-08-04 13:14:44 -07:00
michaela-mm
d9421892fb fix: Check for existing event group in cleanUp() (#9265) 2025-08-01 11:30:23 -07:00
Aaron Dodson
c037e7d47d fix: Scroll CommentBarButtons into view on selection. (#9259) 2025-07-30 09:48:00 -07:00
Aaron Dodson
8a578f5ce3 fix: Allow overriding VariableModel via options.plugins. (#9257) 2025-07-30 08:58:30 -07:00
Maribeth Moffatt
c661dd1c94 fix: dont save ids when copying blocks and comments (#9255) 2025-07-28 14:35:55 -07:00
Aaron Dodson
c9a8221a2d fix: Fix displaying HTML elements in FieldDropdown. (#9258) 2025-07-28 13:33:52 -07:00
Aaron Dodson
3c7add57ee fix: Make non-autoclosing flyouts stay open. (#9245)
* chore: Add tests for toolbox/flyout/focus autoclose behavior.

* fix: Don't force-close non-autoclosing flyouts.
2025-07-18 14:27:49 -07:00
Aaron Dodson
908712e19d fix: Refer to correct replacement method in deprecation warning. (#9237) 2025-07-15 11:06:27 -07:00
Aaron Dodson
7479c2b5c7 fix: Fix order of arguments in IVariableMap.createVariable(). (#9231) 2025-07-14 10:22:09 -07:00
Aaron Dodson
9f66f0c596 fix: Fire a VarTypeChange event when changing a variable's type. (#9236) 2025-07-14 09:53:17 -07:00
Aaron Dodson
52634e4dec fix: Focus the first element in flyouts. (#9228)
* fix: Focus the first element in flyouts.

* refactor: Adjust retrieval of flyout elements.
2025-07-14 08:55:13 -07:00
Aaron Dodson
d5f3d15726 feat: Add support for keyboard navigation to/from block comments. (#9227)
* refactor: Update `TextInputBubble` to use `CommentEditor` for text editing.

* feat: Designate `Bubble` as implementing `IFocusableNode`.

* feat: Dismiss focused bubbles on Escape.

* feat: Add support for keyboard navigation to block comments.

* fix: Scroll comment editors rather than zooming the workspace.

* chore: Add param to docstring.
2025-07-11 10:54:19 -07:00
Ben Henning
5747feef45 fix: Revert drop down and widget div PRs (#9222)
* Revert "fix: Auto-close widget divs on lost focus (#9216)"

This reverts commit bea183d85d.

* Revert "fix: Auto close drop-down divs on lost focus (reapply) (#9213)"

This reverts commit 0e16b0405a.
2025-07-09 12:13:33 -07:00
Ben Henning
bea183d85d fix: Auto-close widget divs on lost focus (#9216)
## The basics

- [x] I [validated my changes](https://developers.google.com/blockly/guides/contribute/core#making_and_verifying_a_change)

## The details
### Resolves

Fixes https://github.com/google/blockly-keyboard-experimentation/issues/563

### Proposed Changes

This expands the functionality introduced in #9213 to also include widget divs.

### Reason for Changes

MakeCode makes use of widget div in several field editors, so the issues described in https://github.com/google/blockly-keyboard-experimentation/issues/563 aren't fully mitigated with #9213 alone.

This PR essentially adds the same support for auto-closing as drop-down divs now have, and enables this functionality by default.

Note the drop-down div change: it was missed in #9123 that the API change for drop-down div's `show` function is actually API-breaking, so this updates that API to be properly backward compatible (and reverts one test change that makes use of it).

The `FocusManager` change actually corrects an implementation issue from #9123: not updating the tracked focus status before calling the callback can result in focus being inadvertently restored if the callback triggers returning focus due to a lost focus situation. This was wrong for drop-down divs, too, but it's harder to notice there because the dismissal of the drop-down div happens on a timer (which means there's sufficient time for `FocusManager`'s state to correct prior to attempting to return from the ephemeral focus state).

Demonstration of fixed behavior (since the inline number editor uses a widget div):

[Screen recording 2025-07-08 2.12.31 PM.webm](https://github.com/user-attachments/assets/7c3c7c3c-224c-48f4-b4af-bde86feecfa8)

### Test Coverage

New widget div tests have been added to verify the new parameter and auto-close functionality.

The `FocusManager` test was updated to account for the new, and correct, behavior around the internal tracked ephemeral focus state.

Note that some `tabindex` state has been clarified and cleaned up in the test index page and `FocusManager`. It's fine (and preferable) for ephemeral-used elements to always be focusable rather than making them dynamically so (which avoids state bleed across test runs which was happening one of the new tests).

https://github.com/google/blockly-keyboard-experimentation/pull/649 includes additional tests for validating widget behaviors.

### Documentation

No new documentation should be needed here--the API documentation changes should be sufficient.

One documentation update was made in `dropdowndiv.ts` that corrects the documentation parameter ordering.

### Additional Information

Nothing further to add.
2025-07-08 16:06:24 -07:00
Maribeth Moffatt
c0489b41e0 feat: add copy api and paste into correct workspace (#9215)
* feat: add copy api and paste into correct workspace

* fix: dont paste into unrendered workspaces

* fix: paste precondition and add test
2025-07-08 16:05:53 -07:00
Aaron Dodson
fc9164de8f fix: Prevent loss of focus when deleting a workspace comment. (#9200)
* fix: Prevent loss of focus when deleting a workspace comment.

* chore: Add test verifying workspace comment focus behavior on deletion.
2025-07-08 13:50:26 -07:00
Ben Henning
0e16b0405a fix: Auto close drop-down divs on lost focus (reapply) (#9213)
## The basics

- [x] I [validated my changes](https://developers.google.com/blockly/guides/contribute/core#making_and_verifying_a_change)

## The details
### Resolves

Fixes https://github.com/google/blockly-keyboard-experimentation/issues/563

### Proposed Changes

This introduces support in `FocusManager` to receive feedback on when an ephemerally focused element entirely loses focus (that is, neither it nor any of its descendants have focus).

This also introduces a behavior change for drop-down divs using the previously mentioned functionality to automatically close themselves when they lose focus for any reason (e.g. clicking outside of the div or tab navigating away from it).

Finally, and **importantly**, this adds a case where ephemeral focus does _not_ automatically return to the previously focused node: when focus is lost to the ephemerally focused element's tree and isn't instead put on another focused node.

### Reason for Changes

Ultimately, focus is probably the best proxy for cases when a drop-down div ought to no longer be open. However, tracking focus only within the scope of the drop-down div utility is rather difficult since a lot of the same problems that `FocusManager` handles also occur here (with regards to both descendants and outside elements receiving focus). It made more sense to expand `FocusManager`'s ephemeral focus support:
- It was easier to implement this `FocusManager` and in a way that's much more robust (since it's leveraging existing event handlers).
- Using `FocusManager` trivialized the solution for drop-down divs.
- There could be other use cases where custom ephemeral focus uses might benefit from knowing when they lose focus.

This new support is enabled by default for all drop-down divs, but can be disabled by callers if they wish to revert to the previous behavior of not auto-closing.

The change for whether to restore ephemeral focus was needed to fix a drawback that arises from the automatic returning of ephemeral focus introduced in this PR: when a user clicks out of an open drop-down menu it will restore focus back to the node that held focus prior to taking ephemeral focus (since it properly hides the drop-down div and restores focus). This creates awkward behavior issues for both mouse and keyboard users:
- For mouse: trying to open a drop-down outside of Blockly will automatically close the drop-down when the Blockly drop-down finishes closing (since focus is stolen back away from the thing the user clicked on).
- For keyboard: tab navigating out of Blockly tries to force focus back to Blockly.

**New in v2 of this PR**: Commit 0363d67c18 is the main one that prevents #9203 from being reintroduced by ensuring that widget div only clears its contents after ephemeral focus has returned. This was missed in the first audit since it wasn't clear that this line, in particular, can cause a div with focus to be removed and thus focus lost: dfd565957b/core/widgetdiv.ts (L156)

### Test Coverage

New tests have been added for both the drop-down div and `FocusManager` components, and have been verified as failing without the new behaviors in place.

There may be other edge cases worth testing for `FocusManager` in particular, but the tests introduced in this PR seem to cover the most important cases.

**New in v2 of this PR**: A test was added to validate that widget div now clears its contents only after ephemeral focus has returned to avoid the desyncing scenario that led to #9203. This test has been verified to fail without the fix. There are also a few new tests being added in the keyboard navigation plugin repository that also validate this behavior at a higher level (see https://github.com/google/blockly-keyboard-experimentation/pull/649).

Demonstration of the new behavior:

[Screen recording 2025-07-01 6.28.37 PM.webm](https://github.com/user-attachments/assets/7af29fed-1ba1-4828-a6cd-65bb94509e72)

### Documentation

No new documentation changes seem needed beyond the code documentation updates.

### Additional Information

It's also possible to change the automatic restoration behavior to be conditional instead of always assuming focus shouldn't be reset if focus leaves the ephemeral element, but that's probably a better change if there's an actual user issue discovered with this approach.

This was originally introduced in #9175 but it was reverted in #9204 due to #9203.
2025-07-07 15:52:38 -07:00
Aaron Dodson
e3d17becbd fix: Improve workspace comment keyboard navigation behavior. (#9211)
* fix: Prevent tabbing into workspace comments.

* fix: Focus workspace comments when navigating to them using the keyboard.
2025-07-07 15:28:54 -07:00