Commit Graph

9097 Commits

Author SHA1 Message Date
Erik Pasternak
9b18a9b75a Work on fixing more browser tests 2025-06-27 15:25:44 -07:00
Richard Knoll
0d6da6cfc4 fix: clear touch identifier on comment text area pointerdown (#9172) 2025-06-26 13:56:08 -07:00
Matt Hillsdon
9cc3e11856 fix: tweak redo shortcut order to match convention (#9169)
The order of the modifiers is not significant to Blockly but it's conventional
to say e.g. Cmd+Shift+Z. Following that order here means that UI like the
keyboard navigation shortcut dialog gets the correct order without having to
sort.
2025-06-26 11:41:01 -07:00
Christopher Allen
f4dbea0a65 refactor(interfaces): Make type predicates more robust (#9150)
* refactor(interfaces): Use typeof ... === 'function' to test for methods

  Testing for

      'name' in object

  or

      obj.name !== undefined

  only checks for the existence of the property (and in the latter
  case that the property is not set to undefined).  That's fine if
  the interface specifies a property of indeterminate type, but in
  the usual case that the interface member is a method we can do
  one better and check to make sure the property's value is
  callable.

* refactor(interfaces): Always check obj is not null/undefined

  Since most type predicates take an argument of type any but then
  check for the existence of certain properties, explicitly check
  that the argument is not null or undefined (or check implicitly
  by calling another type predicate that does so first, which
  necessitates adding a few casts because tsc infers the type of
  the argument too narrowly).

* fix(interfaces): Add missing check to hasBubble type predicate

  This appears to have inadvertently been omitted in PR #9004.

* fix(interfaces): Fix misplaced typeof

* fix: Fix typos in JSDocs

* fix(tests): Make Mocks conform to corresponding interfaces

  Introduce a new MockFocusable, and add methods to MockIcon,
  MockBubbleIcon and MockComment, so that they fulfil the
  IFocusableNode, IIcon, IHasBubble and ICommentIcon interfaces
  respectively.

* chore(tests): Add assertions verifying mocks conform to predicates

  Add (test) runtime assertions that:

  - isFocusableNode(MockFocusable) returns true
  - isIcon(MockIcon) returns true
  - hasBubble(MockBubbleIcon) returns true
  - isCommentIcon(MockCommentIcon) returns true

  (The latter is currently failing because Blockly is undefined when
  isCommentIcon calls the MockCommentIcon's getType method.)

* fix(tests): Don't rely on Blockly being set in Mock methods

  For some reason the global Blockly binding is not visible at the
  time when isCommentIcon calls MockCommentIcon's getType method,
  and presumably this problem would apply to getBubbleSize too,
  so directly import the required items.

* refactor(tests): Make MockCommentIcon a MockBubbleIcon

  This slightly simplifies it and makes it less likely to accidentally
  stop conforming to IHasBubble.

* fix(interfaces): Fix incorrect check in isSelectable

  Fix an error which caused ISelectable instances to fail
  isSelectable() checks, one of the results of which is that
  Blockly.common.getSelected() would generally return null.

  Whoops!
2025-06-25 12:49:37 +01:00
Maribeth Moffatt
eaf5eea98e feat: make comment editor separately focusable from comment itself (#9154)
* feat: make comment editor separately focusable from comment itself

* feat: improve design and add styling

* chore: fix lint

* fix: add event listeners to focus parent comment

* fix: export CommentEditor

* fix: export CommentEditor

* fix: extract comment identifier to constant
2025-06-24 12:40:23 -07:00
dependabot[bot]
5427c3df33 chore(deps): bump mocha from 11.3.0 to 11.7.0 (#9159)
Bumps [mocha](https://github.com/mochajs/mocha) from 11.3.0 to 11.7.0.
- [Release notes](https://github.com/mochajs/mocha/releases)
- [Changelog](https://github.com/mochajs/mocha/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mochajs/mocha/compare/v11.3.0...v11.7.0)

---
updated-dependencies:
- dependency-name: mocha
  dependency-version: 11.7.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-23 12:03:23 -07:00
Ben Henning
af4a4b4100 feat: Run keyboard plugin tests in CI (#9135)
## The basics

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

## The details
### Resolves

N/A (no tracking issue)

### Proposed Changes

Introduces a GitHub actions CI workflow to run the webdriver IO tests from https://github.com/google/blockly-keyboard-experimentation as part of core Blockly's CI.

### Reason for Changes

Since development on the plugin is going to continue for many months yet, this ensures that behavioral changes in core Blockly don't inadvertently break the plugin.

Note that this shouldn't be made a blocking workflow since there may be cases where it's necessary to break the plugin before a change to the plugin itself can be introduced to then fix it (as this has happened many times in the past). However, the CI check is forced signal to both author and reviewer as to whether their change affects the plugin without having to manually check the test suite.

### Test Coverage

N/A -- Verifying that the CI workflow runs is sufficient.

### Documentation

No documentation changes are needed here.

### Additional Information

Nothing.
2025-06-23 11:50:02 -07:00
RoboErikG
4977b4bc9b Merge pull request #9158 from google/dependabot/npm_and_yarn/develop/prettier-3.6.0
chore(deps): bump prettier from 3.3.3 to 3.6.0
2025-06-23 10:03:53 -07:00
RoboErikG
ba90efe80d Merge pull request #9160 from google/dependabot/npm_and_yarn/develop/globals-16.2.0
chore(deps): bump globals from 16.1.0 to 16.2.0
2025-06-23 09:28:33 -07:00
Aaron Dodson
28d6ff7da5 chore: Update messages for keyboard-experiment. (#9152)
* chore: Remove unused messages.

* fix: Remove unneeded message placeholders.

* feat: Add additional messages used in the keyboard experiment.

* chore: Update messages.
2025-06-23 09:14:39 -07:00
dependabot[bot]
21216e85d3 chore(deps): bump prettier from 3.3.3 to 3.6.0
Bumps [prettier](https://github.com/prettier/prettier) from 3.3.3 to 3.6.0.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.3.3...3.6.0)

---
updated-dependencies:
- dependency-name: prettier
  dependency-version: 3.6.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-23 16:11:39 +00:00
dependabot[bot]
253ea15ab4 chore(deps): bump eslint-plugin-prettier from 5.4.0 to 5.5.0 (#9157)
Bumps [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) from 5.4.0 to 5.5.0.
- [Release notes](https://github.com/prettier/eslint-plugin-prettier/releases)
- [Changelog](https://github.com/prettier/eslint-plugin-prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/eslint-plugin-prettier/compare/v5.4.0...v5.5.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-prettier
  dependency-version: 5.5.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-23 09:10:52 -07:00
Aaron Dodson
1e5b4e9f42 feat: Add support for keyboard navigation into mutator workspaces. (#9151)
* feat: Add support for keyboard navigation into mutators.

* fix: Prevent mutator bubbles from jumping wildly during keyboard nav.
2025-06-23 09:09:56 -07:00
dependabot[bot]
acdb27ee67 chore(deps): bump globals from 16.1.0 to 16.2.0
Bumps [globals](https://github.com/sindresorhus/globals) from 16.1.0 to 16.2.0.
- [Release notes](https://github.com/sindresorhus/globals/releases)
- [Commits](https://github.com/sindresorhus/globals/compare/v16.1.0...v16.2.0)

---
updated-dependencies:
- dependency-name: globals
  dependency-version: 16.2.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-23 11:25:33 +00:00
dependabot[bot]
97ffea73be chore(deps): bump @hyperjump/browser from 1.1.6 to 1.3.1 (#9148)
Bumps [@hyperjump/browser](https://github.com/hyperjump-io/browser) from 1.1.6 to 1.3.1.
- [Commits](https://github.com/hyperjump-io/browser/compare/v1.1.6...v1.3.1)

---
updated-dependencies:
- dependency-name: "@hyperjump/browser"
  dependency-version: 1.3.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-18 12:29:03 -07:00
Maribeth Moffatt
cf3fcccec1 fix: caret position when editing block comments (#9153) 2025-06-18 11:15:41 -07:00
Aaron Dodson
afe53c5194 fix: Dispatch keyboard events with the workspace they occurred on. (#9137)
* fix: Dispatch keyboard events with the workspace they occurred on.

* chore: Add comment warding off would-be refactorers.
2025-06-16 15:45:01 -07:00
RoboErikG
7df501d7af fix: Add isCopyable to the ICopyable interface and use it for cut/copy preconditions
Merge pull request #9134 from RoboErikG/is-copyable
2025-06-16 12:47:53 -07:00
Erik Pasternak
2bae8eb377 Update isCopyable comment 2025-06-16 12:38:46 -07:00
RoboErikG
f117bbad22 Simplify check for existence of isCopyable
Co-authored-by: Christopher Allen <cpcallen+github@gmail.com>
2025-06-16 12:35:10 -07:00
dependabot[bot]
3e09a70ef4 chore(deps): bump @hyperjump/json-schema from 1.11.0 to 1.15.1 (#9147)
Bumps [@hyperjump/json-schema](https://github.com/hyperjump-io/json-schema) from 1.11.0 to 1.15.1.
- [Commits](https://github.com/hyperjump-io/json-schema/compare/v1.11.0...v1.15.1)

---
updated-dependencies:
- dependency-name: "@hyperjump/json-schema"
  dependency-version: 1.15.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-16 17:36:27 +01:00
Aaron Dodson
93a9b6bf2e fix: Fix navigation for blocks with multiple statement inputs. (#9143)
* fix: Fix navigation for blocks with multiple statement inputs.

* chore: Add tests to prevent regressions.
2025-06-13 15:08:58 -07:00
Erik Pasternak
a88836227c Add tests for workspace comments 2025-06-13 13:07:53 -07:00
Aaron Dodson
fd5a7f4a18 refactor: Make the cursor use the focus manager for tracking the current node. (#9142) 2025-06-13 12:05:00 -07:00
Erik Pasternak
32bb84ec8f Allow copying from readonly workspace and add cut tests
Also cleans up logic a bit
2025-06-13 11:57:03 -07:00
Erik Pasternak
f1b44db6f4 Add missing bang 2025-06-10 13:52:14 -07:00
Erik Pasternak
428e4475bf Simplify cut/copy logic 2025-06-10 13:32:36 -07:00
Erik Pasternak
1d4e531ebe Don't allow things in a flyout to be deleted or moved. 2025-06-10 11:24:42 -07:00
Erik Pasternak
e1441d5308 Remove isCuttable api 2025-06-10 11:12:04 -07:00
Erik Pasternak
46078369c2 Fix build errors 2025-06-09 15:33:45 -07:00
Erik Pasternak
9685498d21 Add isCopyable and isCuttable as optional methods on ICopyable 2025-06-09 15:13:43 -07:00
RoboErikG
02f89d6f96 Merge pull request #9132 from google/dependabot/npm_and_yarn/develop/eslint-plugin-jsdoc-50.7.1
chore(deps): bump eslint-plugin-jsdoc from 50.6.9 to 50.7.1
2025-06-09 10:06:50 -07:00
dependabot[bot]
10085693e5 chore(deps): bump eslint-plugin-jsdoc from 50.6.9 to 50.7.1
Bumps [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) from 50.6.9 to 50.7.1.
- [Release notes](https://github.com/gajus/eslint-plugin-jsdoc/releases)
- [Changelog](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/.releaserc)
- [Commits](https://github.com/gajus/eslint-plugin-jsdoc/compare/v50.6.9...v50.7.1)

---
updated-dependencies:
- dependency-name: eslint-plugin-jsdoc
  dependency-version: 50.7.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-09 09:48:50 +00:00
RoboErikG
74dbed2769 Merge pull request #9127 from google/dependabot/npm_and_yarn/npm_and_yarn-762e3aa393
chore(deps-dev): bump tar-fs from 3.0.8 to 3.0.9 in the npm_and_yarn group across 1 directory
2025-06-06 10:52:43 -07:00
dependabot[bot]
2f7ece86ff chore(deps-dev): bump tar-fs
Bumps the npm_and_yarn group with 1 update in the / directory: [tar-fs](https://github.com/mafintosh/tar-fs).


Updates `tar-fs` from 3.0.8 to 3.0.9
- [Commits](https://github.com/mafintosh/tar-fs/compare/v3.0.8...v3.0.9)

---
updated-dependencies:
- dependency-name: tar-fs
  dependency-version: 3.0.9
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-03 06:46:53 +00:00
dependabot[bot]
b5dbe6acfb chore(deps): bump @blockly/dev-tools from 9.0.0 to 9.0.1 (#9124)
Bumps [@blockly/dev-tools](https://github.com/google/blockly-samples/tree/HEAD/plugins/dev-tools) from 9.0.0 to 9.0.1.
- [Release notes](https://github.com/google/blockly-samples/releases)
- [Changelog](https://github.com/google/blockly-samples/blob/master/plugins/dev-tools/CHANGELOG.md)
- [Commits](https://github.com/google/blockly-samples/commits/@blockly/dev-tools@9.0.1/plugins/dev-tools)

---
updated-dependencies:
- dependency-name: "@blockly/dev-tools"
  dependency-version: 9.0.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-02 09:59:42 -07:00
RoboErikG
0f6454b41d release: Blockly v12.1.0 merge master into develop
Merge pull request #9120 from RoboErikG/develop
2025-05-30 14:15:03 -07:00
Maribeth Moffatt
60fc20acef release: Blockly v12.1.0
Merge pull request #9119 from google/rc/v12.1.0
2025-05-30 13:37:36 -07:00
Maribeth Moffatt
2ea750f30a release: update version number to 12.1.0 blockly-v12.1.0 2025-05-30 13:30:29 -07:00
Maribeth Moffatt
0d5cc017cd release: merge develop into v12.1.0
Merge pull request #9118 from maribethb/rc/v12.1.0
2025-05-30 13:29:10 -07:00
Maribeth Moffatt
2ffd3cbb1d release: merge branch develop into rc/v12.1.0 2025-05-30 13:18:48 -07:00
Aaron Dodson
cb0824736b fix: Fix bug that caused the focus manager to attempt to focus unfocusable elements. (#9117) 2025-05-30 13:09:52 -07:00
Maribeth Moffatt
d1b17d1f90 fix: context menus on flyout (#9116) 2025-05-30 11:00:56 -07:00
RoboErikG
fdffd6558b fix: Make cut/copy/paste work consistently and as expected (#9107)
* Work on cut/copy/paste preconditions

* Cleanup and fixes to cut/copy/paste

* Fix tests

* Remove editable check from isCopyable and isCuttable
2025-05-30 10:49:30 -07:00
Maribeth Moffatt
3ccfba9c4b feat: ephemeral focus public getter, use in shortcut precondition (#9110) 2025-05-30 09:42:23 -07:00
Maribeth Moffatt
f41687524a release: merge branch develop into rc/v12.1.0 2025-05-29 15:04:58 -07:00
Maribeth Moffatt
0498ed6174 feat: add keyboard navigation controller (#8924)
* feat: add keyboard navigation controller

* chore: add tests

* chore: fix tsdoc
2025-05-29 13:48:54 -07:00
Ben Henning
3cbca8e4b6 feat: Automatically manage focus tree tab indexes (#9079)
## The basics

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

## The details
### Resolves

Fixes #8965
Fixes #8978
Fixes #8970
Fixes https://github.com/google/blockly-keyboard-experimentation/issues/523
Fixes https://github.com/google/blockly-keyboard-experimentation/issues/547
Fixes part of #8910

### Proposed Changes

Fives groups of changes are included in this PR:
1. Support for automatic tab index management for focusable trees.
2. Support for automatic tab index management for focusable nodes.
3. Support for automatically hiding the flyout when back navigating from the toolbox.
4. A fix for `FocusManager` losing DOM syncing that was introduced in #9082.
5. Some cleanups for flyout and some tests for previous behavior changes to `FocusManager`.

### Reason for Changes

Infrastructure changes reasoning:
- Automatically managing tab indexes for both focusable trees and roots can largely reduce the difficulty of providing focusable nodes/trees and generally interacting with `FocusManager`. This facilitates a more automated navigation experience.
- The fix for losing DOM syncing is possibly not reliable, but there are at least now tests to cover for it. This may be a case where a `try{} finally{}` could be warranted, but the code will stay as-is unless requested otherwise.

`Flyout` changes:
- `Flyout` no longer needs to be a focusable tree, but removing that would be an API breakage. Instead, it throws for most of the normal tree/node calls as it should no longer be used as such. Instead, its workspace has been made top-level tabbable (in addition to the  main workspace) which solves the extra tab stop issues and general confusing inconsistencies between the flyout, toolbox, and workspace.
- `Flyout` now correctly auto-selects the first block (#9103 notwithstanding). Technically it did before, however the extra `Flyout` tabstop before its workspace caused the inconsistency (since focusing the `Flyout` itself did not auto-select, only selecting its workspace did).

Important caveats:
- `getAttribute` is used in place of directly fetching `.tabIndex` since the latter can apparently default to `-1` (and possibly `0`) in cases when it's not actually set. This is a very surprising behavior that leads to incorrect test results.
- Sometimes tab index still needs to be introduced (such as in cases where native DOM focus is needed, e.g. via `focus()` calls or clicking). This is demonstrated both by updates to `FocusManager`'s tests as well as toolbox's category and separator. This can be slightly tricky to miss as large parts of Blockly now depend on focus to represent their state, so clicking either needs to be managed by Blockly (with corresponding `focusNode` calls) or automatic (with a tab index defined for the element that can be clicked, or which has a child that can be clicked).

Note that nearly all elements used for testing focus in the test `index.html` page have had their tab indexes removed to lean on `FocusManager`'s automatic tab management (though as mentioned above there is still some manual tab index management required for `focus()`-specific tests).

### Test Coverage

New tests were added for all of the updated behaviors to `FocusManager`, including a new need to explicitly provide (and reset) tab indexes for all `focus()`-esque tests. This also includes adding new tests for some behaviors introduced in past PRs (a la #8910).

Note that all of the new and affected conditionals in `FocusManager` have been verified as having at least 1 test that breaks when it's removed (inverted conditions weren't thoroughly tested, but it's expected that they should also be well covered now).

Additional tests to cover the actual navigation flows will be added to the keyboard experimentation plugin repository as part of https://github.com/google/blockly-keyboard-experimentation/pull/557 (this PR needs to be merged first).

For manual testing, I mainly verified keyboard navigation with some cursory mouse & click testing in the simple playground. @rachel-fenichel also performed more thorough mouse & click testing (that yielded an actual issue that was fixed--see discussion below).

The core webdriver tests have been verified to have seemingly the same existing failures with and without these changes.

All of the following new keyboard navigation plugin tests have been verified as failing without the fixes introduced in this branch (and passing with them):
- `Tab navigating to flyout should auto-select first block`
- `Keyboard nav to different toolbox category should auto-select first block`
- `Keyboard nav to different toolbox category and block should select different block`
- `Tab navigate away from toolbox restores focus to initial element`
- `Tab navigate away from toolbox closes flyout`
- `Tab navigate away from flyout to toolbox and away closes flyout`
- `Tabbing to the workspace after selecting flyout block should close the flyout`
- `Tabbing to the workspace after selecting flyout block via workspace toolbox shortcut should close the flyout`
- `Tabbing back from workspace should reopen the flyout`
- `Navigation position in workspace should be retained when tabbing to flyout and back`
- `Clicking outside Blockly with focused toolbox closes the flyout`
- `Clicking outside Blockly with focused flyout closes the flyout`
- `Clicking on toolbox category focuses it and opens flyout`

### Documentation

No documentation changes are needed beyond the code doc changes included in the PR.

### Additional Information

An additional PR will be introduced for the keyboard experimentation plugin repository to add tests there (see test coverage above). This description will be updated with a link to that PR once it exists.
2025-05-29 12:09:59 -07:00
Aaron Dodson
fd0c08e950 fix: Copy shortcuts before returning them (#9109) 2025-05-29 09:59:45 -07:00
Aaron Dodson
38df7c8776 feat: Allow visiting empty input connections. (#9104)
* feat: Update navigation policies to allow visiting empty input connections.

* fix: Fix tests.

* chore: Add JSDoc.

* fix: Add missing import.

* fix: Fix JSDoc.

* chore: Remove double comments.
2025-05-28 20:43:16 -07:00