fix: resolve promotion dialog bugs and column resizing issues
CI Pipeline / Code Linting (pull_request) Successful in 13s
CI Pipeline / Build Verification (pull_request) Has been skipped
CI Pipeline / Generate Quality Report (pull_request) Successful in 22s
CI Pipeline / Run Tests (pull_request) Failing after 21s

This commit addresses three critical bugs reported after initial PR:

1. **Promotion dialog not closing after piece selection**
   - Changed from `style.display` to HTML5 `.showModal()` and `.close()`
   - Fixed selector from `.promotion-piece .symbol` to `.promotion-piece .piece-icon`
   - Fixed data attribute from `dataset.type` to `dataset.piece`
   - Dialog now properly closes after user selects promotion piece

2. **Pawn showing as queen before user selection**
   - Removed automatic promotion to queen in GameController.js:112-115
   - Now emits 'promotion' event WITHOUT pre-promoting
   - User sees pawn until they select the promotion piece
   - Promotion happens only after user makes their choice

3. **Column resizing not fully fixed**
   - Added explicit `max-width: 250px` to `.game-sidebar` and `.captured-pieces`
   - Added explicit `max-width: 250px` to `.move-history-section`
   - Added `overflow: hidden` to `.captured-list` and `overflow-x: hidden` to `.move-history`
   - Added `min-width: 600px` to `.board-section`
   - Added `width: 100%` to all sidebar components for proper constraint application
   - Columns now maintain stable widths even with content changes

**Files Changed:**
- `js/main.js` - Fixed promotion dialog handling
- `js/controllers/GameController.js` - Removed auto-promotion
- `css/main.css` - Added width constraints and overflow handling

**Root Causes:**
- Dialog: Mixing HTML5 dialog API with legacy display styles
- Promotion: Auto-promoting before showing user dialog
- Resizing: Missing explicit max-widths allowed flex items to grow with content

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Christoph Wagner
2025-11-23 19:28:45 +01:00
co-authored by Claude
parent fb96963b48
commit e88e67de4b
3 changed files with 22 additions and 18 deletions
+3 -6
View File
@@ -108,14 +108,11 @@ export class GameController {
const moveResult = this.board.movePiece(fromRow, fromCol, toRow, toCol);
captured = moveResult.captured;
// Check for promotion
// Check for promotion - emit event WITHOUT auto-promoting
if (specialMoveType === 'promotion' || (piece.type === 'pawn' && piece.canPromote())) {
// Default to queen, UI should prompt for choice
const newPiece = SpecialMoves.promote(this.board, piece, 'queen');
promotedTo = newPiece.type;
// Emit promotion event for UI to handle
// Emit promotion event for UI to handle - DON'T auto-promote yet
this.emit('promotion', { pawn: piece, position: { row: toRow, col: toCol } });
// promotedTo will be set when the UI calls back with the chosen piece
}
}