forked from scratchfoundation/scratch-gui
-
-
Notifications
You must be signed in to change notification settings - Fork 16
feat: implement block display settings dialog #380
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Added GUI settings screen equivalent to only_blocks URL parameter functionality. This provides users with an intuitive interface to control which block categories are visible in the workspace. Features: - Block display settings modal dialog accessible from Settings menu - Individual category toggles for Motion, Looks, Sound, Events, Control, Sensing, Operators - Select All and Select None buttons for quick selection - Always-visible categories (Variables, My Blocks, Extensions) shown as disabled - Integration with existing only_blocks URL parameter (URL takes priority) - Redux state management for settings persistence - Responsive modal design with proper styling Components added: - BlockDisplayModal component and container - Block display reducer for state management - Settings menu integration - Blocks container integration for functionality Fixes #370 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Fixed two critical issues with block display functionality:
1. Events category ID mismatch in makeToolboxXML
- Fixed moveCategory('event') to moveCategory('events') in make-toolbox-xml.js
- This resolves the issue where events category wasn't being recognized
2. Enhanced Redux state monitoring for GUI settings
- Added selectedCategories comparison in shouldComponentUpdate
- Added toolbox update trigger in componentDidUpdate when selectedCategories changes
- This ensures GUI settings changes are immediately reflected in block display
Technical changes:
- src/lib/make-toolbox-xml.js: Fixed events category lookup
- src/containers/blocks.jsx: Enhanced Redux state change monitoring
- src/components/block-display-modal/block-display-modal.jsx: Fixed ESLint errors
Partial fix for #370 - GUI settings now properly integrate with block filtering
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Enhanced block display filtering functionality: 1. Fixed GUI settings condition logic - Removed length > 0 condition that prevented initial filtering - GUI settings now properly apply when selectedCategories exists 2. Added empty category selection handling - When no categories selected, show only Variables and My Blocks - Implements proper "hide all blocks" functionality 3. Improved filtering logic robustness - Better handling of undefined/null selectedCategories - Cleaner conditional structure for URL vs GUI settings priority Manual testing shows: - GUI settings integration: ✅ Working - Empty category filtering: ✅ Working - Individual category selection: ✅ Working - Initial state Events/Operators: ❌ Still investigating Partial progress on #370 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Fixed the root cause of Events/Operators not displaying in initial state: **Problem**: - GUI settings used 'events'/'operators' IDs - make-toolbox-xml.js expects 'event_'/'operator_' prefixes - Filtering failed due to ID mismatch **Solution**: - Updated Redux initial state: 'events' → 'event', 'operators' → 'operator' - Updated container handleSelectAll: matching ID changes - Updated modal BLOCK_CATEGORIES: matching ID changes - Preserved display names as 'Events' and 'Operators' - Removed debug logging for clean production code **Testing Results**: ✅ Initial state: All categories including Events/Operators now display correctly ✅ GUI settings integration: Working perfectly ✅ Empty category filtering: Working perfectly ✅ Individual category selection: Working perfectly ✅ Select All/None buttons: Working perfectly Complete fix for #370 - Block display settings dialog fully functional 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Author
Aligned Block Display Modal styling to match Debug Modal appearance: **Visual Improvements:** - Green header background ($ui-green-2) with white text, matching Debug Modal - Moved close button (×) to header right side with hover effects - Updated modal structure: separated header and body sections - Applied consistent 8px border radius and shadow effects - Unified padding and spacing with Debug Modal standards **Fixed Title Duplication:** - Added headerClassName to hide default Modal component header - Eliminated duplicate "Block Display Settings" titles - Clean single-header design matching Debug Modal pattern **Technical Changes:** - Restructured JSX: header + body layout instead of header inside body - Added .hiddenHeader CSS class to suppress default modal header - Removed footer section, integrated close functionality in header - Maintained responsive design and RTL support **Result:** Block Display Modal now has consistent visual design with Debug Modal, providing unified user experience across settings dialogs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…ecture Complete architectural refactoring to align with Debug Modal implementation: **Implementation Changes:** - Replaced Modal container with direct ReactModal usage - Adopted Debug Modal's component structure and patterns - Eliminated dependency on custom Modal wrapper component **Technical Improvements:** - ReactModal with custom overlay/container class names - Proper modal structure: modalHeader + modalContent separation - Scoped CSS with .block-display-modal-container prefix - Consistent z-index and positioning with Debug Modal **View Structure Alignment:** - Header: Green background with white text and close button - Content: Scrollable content area with proper padding - Overlay: Transparent overlay with center alignment - Responsive: Maintained mobile-friendly design **Code Quality:** - Removed unused Box components, replaced with semantic divs - Cleaned up unused props and imports - Proper CSS scoping to prevent style conflicts - Maintained RTL support and responsive breakpoints **Result:** Block Display Modal now shares identical architecture and visual patterns with Debug Modal, ensuring consistent user experience and maintainable code structure. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Modified block display modal CSS and JSX components for improved functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Use ScratchBlocks.Msg.CATEGORY_XXX for standard category translations - Add Block Display menu translations to all language files - Update myBlocks translation to "ブロック定義" in Japanese - Remove custom category translations in favor of scratch-l10n standard - Pass VM to BlockDisplayModal component for ScratchBlocks access 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add 2-pane modal structure (category list + block list) - Implement block definitions for all 7 categories (100+ blocks) - Add ScratchBlocks.Msg translation for block names - Add navigation arrows for category switching - Add individual block checkboxes for granular control - Implement responsive design with proper CSS styling - Add new translation keys for UI elements (3 languages) - Fix lint errors and build compatibility Features: - Left pane: Category selection, bulk controls, always-visible categories - Right pane: Block list with checkboxes, navigation, translated names - Debug Modal-inspired navigation with prev/next arrows - Educational use case support for progressive learning 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Author
- Add individual block visibility control with Redux state management - Implement 3-state category checkboxes (checked/unchecked/indeterminate) - Add block-level checkboxes that sync with category state - Category checkboxes now properly reflect child block selection: - Checked: all blocks in category visible - Unchecked: no blocks in category visible - Indeterminate: some blocks visible, others hidden - Update Select All/None to handle both categories and blocks - Fix checkbox interaction logic where category changes affect all blocks - Ensure proper state synchronization between category and block levels This resolves the issue where unchecking a category (e.g. Motion) would not properly hide all blocks in that category, implementing true block-level display control as requested in Issue #370. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…splay modal - Remove label wrapper that caused category name clicks to toggle checkboxes - Category name text now only selects category for right pane view - Checkbox clicks are now isolated to only the checkbox element itself - Update CSS styling to maintain visual consistency without label wrapper: - Add gap and flex properties to categoryItem and categoryName - Move cursor, user-select, and font-weight to categoryName - Remove cursor pointer from categoryItem container - Improve UX by preventing accidental checkbox toggling when browsing categories This ensures users can click category names (e.g. "動き") to view blocks without accidentally changing checkbox states, while still allowing direct checkbox interaction for visibility control. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit fixes the core filtering architecture to enable individual block visibility control in the toolbox based on block display modal selections. Key changes: - Fixed React component lifecycle: Use reference equality instead of JSON.stringify for selectedBlocks comparison in shouldComponentUpdate and componentDidUpdate - Fixed Redux state immutability: Implement deep copying in reducer to ensure new object references for React change detection - Inverted filtering architecture: Block checkboxes now directly control toolbox visibility, category checkboxes control block checkboxes only - Fixed category naming consistency: Use 'events'/'operators' to match XML structure instead of 'event'/'operator' - Integrated with existing makeToolboxXML onlyBlocks parameter for filtering implementation The block display modal now correctly: - Hides individual blocks when unchecked (e.g., unchecking motion_movesteps removes it from the toolbox) - Updates toolbox in real-time without requiring modal close - Maintains 3-state checkbox behavior for category controls - Preserves all existing filtering functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Remove 'Select All' and 'Deselect All' buttons (すべて選択、すべて選択解除ボタンの廃止) from the block display modal component. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Add vertical scrolling to block list in right pane: - Set max-height and min-height for .blockList container - Header with category title and navigation buttons remains fixed - Block list content scrolls independently - Applies to all block categories 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove @media queries for mobile/small screens - Keep fixed modal size (900px × 600px) at all screen sizes - Remove responsive layout changes for controls and body 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Change modal width from 900px to 500px - Adjust left pane width from 300px to 180px - Right pane automatically adjusts with flex: 1 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Change block display modal height from 600px to 560px 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Set explicit height calculations for left and right panes - Formula: calc(560px - 4px * 2 - 50px) for modal content height - Remove max-height constraints from .blockList to allow proper scrolling - Fixes issue where scrollbar was not visible due to content overflow 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Change left pane background to white (#FFFFFF) - Change right pane background to light gray (#F9F9F9) - Improve visual consistency with design specifications 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add category-specific colors for checkboxes matching block categories - Implement custom checkbox styling with appearance: none - Add support for three checkbox states: unchecked (□), checked (✓), indeterminate (−) - Position checkmarks and indeterminate marks centered in checkboxes - Apply consistent styling to both category and block checkboxes - Update active category background to #E9EEF2 Category colors: - Motion: blue (#4C97FF/#3373CC) - Looks: purple (#9966FF/#774DCD) - Sound: magenta (#CF63CF/#BD42BD) - Events: yellow (#FFBF00/#CC9900) - Control: orange (#FFAB19/#CF8B17) - Sensing: light blue (#5CB1D6/#2E8EB8) - Operators: teal (#0FBD8C/#0B8E69) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Update handleCategoryChange to find clicked category index - Set selectedCategoryIndex state to sync right pane display - Maintain existing onCategoryChange functionality - Enable seamless category switching via checkbox interaction 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Handle typo in scratch-l10n message key mapping - Map sound_seteffectto to SOUND_SETEFFECTO (correct key in l10n) - Enable proper Japanese display: "%1 の効果を %2 にする" - Fix missing localization for sound effect blocks 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Fix operator blocks: map operator_ prefix to OPERATORS_ (plural form) - Fix control blocks: map specific blocks to correct message keys - control_if_else → CONTROL_IF - control_wait_until → CONTROL_WAITUNTIL - control_repeat_until → CONTROL_REPEATUNTIL - control_start_as_clone → CONTROL_STARTASCLONE - control_create_clone_of → CONTROL_CREATECLONEOF - control_delete_this_clone → CONTROL_DELETETHISCLONE - Enable proper Japanese display for all control and operator blocks - Resolve inconsistent message key naming patterns in scratch-l10n 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Map control_stop to CONTROL_STOP_ALL for proper Japanese display - Fix empty space issue where CONTROL_STOP was mapped to " " (full-width space) - Now displays "すべてを止める" instead of blank space - Complete Japanese localization for control blocks 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add special mapping for operator_letter_of to OPERATORS_LETTEROF - Fix underscore mismatch in message key naming - Enable proper Japanese display: "%2 の %1 番目の文字" - Complete localization for all operator blocks 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Modified BlockDisplayModal to use custom localization system for block names - Maintained ScratchBlocks.Msg for category names and titles for compatibility - Updated message catalogs (en.js, ja.js, ja-Hira.js) with gui.smalruby3.blockDisplayModal prefix - Block names now use intl.formatMessage with custom message IDs - Removed unnecessary getBlockMessageKey function and related processing 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…ments - Replaced generic placeholders (%1, %2) with concrete example values and UI elements - Added dropdown indicators (▼) and specific values like (10), (こんにちは), etc. - Enhanced readability by showing actual block appearance with default values - Made translations more intuitive for Japanese users learning block programming 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…isual elements - Updated en.js with specific English values based on scratch-l10n references - Enhanced ja.js with visual symbols (🏁, ↻, ↺, 🎨) and consistent formatting - Updated ja-Hira.js with hiragana translations and concrete example values - Replaced abstract placeholders (%1, %2) with intuitive UI examples across all languages - Added dropdown indicators (▼) and specific values for better user comprehension - Improved accessibility with hiragana alternatives for Japanese learners 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Modified right pane to show all block categories in vertical list - Added category headers with styling for better organization - Removed navigation buttons and related unused code - Each category displays its blocks with checkboxes in single column - Improved block list layout with proper spacing and category separation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Add scroll-based synchronization between right pane block list and left pane category highlighting: - Add handleBlockListScroll method to detect most visible category section - Implement scroll event listener on block list container with ref - Automatically update selectedCategoryIndex based on scroll position - Calculate visible area of each category section to determine active category This implements step 2 of the three-part UI enhancement: when users scroll through the block list, the corresponding category in the left pane becomes active/highlighted automatically. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…odal Add synchronized scrolling from left pane category clicks to right pane block sections: - Modify handleCategoryChange to scroll to corresponding category section when checkbox is toggled - Modify handleCategorySelect to scroll when category name is clicked - Add scrollToCategorySection method with smooth scrolling behavior - Calculate target section offset and scroll to exact position This completes step 3 of the three-part UI enhancement: clicking categories in the left pane now automatically scrolls to the corresponding blocks in the right pane with smooth animation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…ponent Fix React warning about function components not accepting refs: - Replace React.createRef() with null initialization - Add setBlockListRef callback method to bindAll - Use componentRef prop instead of ref prop for Box component - Update scroll detection methods to work with callback ref This fixes the "Function components cannot be given refs" warning and ensures proper DOM element access for scroll functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Improve scroll synchronization to activate categories when their header reaches the top of viewport: - Change from visible area calculation to header position detection - Use categoryHeader elements as trigger points instead of sections - Add 50px offset tolerance for smooth transition timing - Find header closest to container top with proper distance calculation This ensures categories become active when their header text becomes visible at the top, providing more intuitive visual feedback during scrolling. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Clean up debug logging and set optimal offset for category activation: - Remove all console.log statements from scroll handler - Set 180px offset for smooth category switching timing - Categories activate when their headers approach viewport top - Provides intuitive visual feedback during block list scrolling The scroll detection now properly activates categories when their header sections become visible at the top of the right pane. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Improve scroll position when clicking category names or checkboxes: - Increase scroll offset from 180px to 200px for better header positioning - Ensure clicked category headers appear at optimal viewport position - Maintain consistency with scroll detection timing - Use Math.max(0, scrollPosition) to prevent negative scroll values This provides more precise positioning when users click categories in the left pane, ensuring the target category is properly visible. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Ensure perfect alignment between scroll detection and click-based scrolling: - Revert click-based scrolling offset from 200px back to 180px - Now both scroll detection and click scrolling use identical 180px offset - Categories clicked in left pane scroll to exact position that triggers active state detection in scroll handler This eliminates the mismatch where clicking a category would scroll but leave a different category active. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Add eslint-disable comment for intentionally unused categoryId parameter in filterBlocksInCategory function: - Parameter is required by function signature and call sites - Currently unused but reserved for future logging functionality - Updated JSDoc to clarify parameter is currently unused - Resolves no-unused-vars lint error 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Fixed formatting issues and circular import problems that were causing Chrome browser crashes during integration tests. The changes include: - Export CATEGORY_BLOCKS to make it available for import in make-toolbox-xml.js - Fix whitespace formatting issues throughout block-display-modal.jsx - Add proper block counting logic to prevent unnecessary filtering - Improve block filtering logic to handle default all-blocks state 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Updated package dependencies to support block-display-modal functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
github-actions bot
pushed a commit
that referenced
this pull request
Aug 30, 2025
…-display-settings-dialog feat: implement block display settings dialog
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.


Block Display Settings Dialog Enhancement
Overview
This PR implements a comprehensive enhancement to the Block Display Settings dialog, transforming it from a basic settings modal into a sophisticated block management interface with advanced scroll-based interactions and visual improvements.
Key Features
🎨 Visual Design Improvements
rgb(76, 151, 255)rgb(153, 102, 255)rgb(207, 99, 207)rgb(255, 191, 0)rgb(255, 171, 25)rgb(92, 177, 214)rgb(15, 189, 140)#E9EEF2background🔄 Advanced UI Interactions
1. Vertical Block List Display
2. Scroll-Based Category Detection
3. Click-Based Category Navigation
🌐 Comprehensive Localization System
Custom Message Catalog
gui.smalruby3.blockDisplayModal.prefixTranslation Examples
'motion_movesteps': 'move (10) steps''motion_movesteps': '(10) 歩動かす''motion_movesteps': '(10) ほうごかす'🛠 Technical Implementations
React Component Enhancements
selectedCategoryIndexfor tracking active categoriescomponentRefcallback implementation for scroll containerhandleBlockListScroll(): Viewport-based category detectionscrollToCategorySection(): Smooth scroll navigationhandleCategorySelect(): Click-based category activationPerformance Optimizations
Implementation Details
Core Algorithm: Scroll Detection
Synchronized Navigation
Files Modified
Core Components
src/components/block-display-modal/block-display-modal.jsx- Main component logicsrc/components/block-display-modal/block-display-modal.css- Visual stylingLocalization Files
src/locales/en.js- English translations with concrete examplessrc/locales/ja.js- Japanese translations with visual symbolssrc/locales/ja-Hira.js- Hiragana accessibility translationsBuild Fixes
src/lib/make-toolbox-xml.js- ESLint error resolutionUser Experience Improvements
Testing Coverage
Breaking Changes
None - fully backward compatible with existing block display functionality.
Migration Notes
The enhancement maintains all existing functionality while adding new interactive features. No migration steps required.
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com