Skip to content

Fix: Correct screen reader announcement order for blocks#1678

Merged
PranavPurwar merged 1 commit intoSketchware-Pro:mainfrom
makhlwf:fix/screen-reader-block-name
Jun 18, 2025
Merged

Fix: Correct screen reader announcement order for blocks#1678
PranavPurwar merged 1 commit intoSketchware-Pro:mainfrom
makhlwf:fix/screen-reader-block-name

Conversation

@makhlwf
Copy link
Contributor

@makhlwf makhlwf commented Jun 18, 2025

Previously, screen readers would announce block names (e.g., "SetActivityTitle") in a misparsed order (e.g., "Activity, title, set"). This was likely due to default accessibility behavior splitting the CamelCase name and reordering it.

This commit addresses the issue by modifying PaletteBlock.java:

  1. A helper function generateContentDescription(String name) was added to convert CamelCase/PascalCase names into a space-separated format (e.g., "SetActivityTitle" becomes "Set Activity Title").
  2. The methods responsible for creating block views (Rs instances) now use this helper function to generate a contentDescription from the block's opCode (which typically holds the CamelCase name).
  3. This generated contentDescription is then explicitly set on the block view, ensuring screen readers announce the name in the correct, intended order.

Warning, the changes are made with AI. I have tested the fix by building the project and everything seems to work correctly. But if you want to merge this, please review it carefully. To see if it edited any existing functionality or if it broke it, because I'm not a Java developer.

thanks

Previously, screen readers would announce block names (e.g., "SetActivityTitle")
in a misparsed order (e.g., "Activity, title, set"). This was likely due to
default accessibility behavior splitting the CamelCase name and reordering it.

This commit addresses the issue by modifying `PaletteBlock.java`:
1. A helper function `generateContentDescription(String name)` was added to
   convert CamelCase/PascalCase names into a space-separated format
   (e.g., "SetActivityTitle" becomes "Set Activity Title").
2. The methods responsible for creating block views (`Rs` instances) now
   use this helper function to generate a `contentDescription` from
   the block's opCode (which typically holds the CamelCase name).
3. This generated `contentDescription` is then explicitly set on the
   block view, ensuring screen readers announce the name in the correct,
   intended order.

I recommend that you manually test with an accessibility inspector and a screen reader (like TalkBack)
to confirm the fix across various block types.
Copy link
Collaborator

@PranavPurwar PranavPurwar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@PranavPurwar PranavPurwar added the fix This pull request contains a bugfix label Jun 18, 2025
@PranavPurwar PranavPurwar merged commit 307d821 into Sketchware-Pro:main Jun 18, 2025
@trindadedev13 trindadedev13 added the merged This pull request was merged, it's only GitHub not showing it as merged. label Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix This pull request contains a bugfix merged This pull request was merged, it's only GitHub not showing it as merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants