Fix missing ARIA attributes on dynamically inserted chapter rows#161
Conversation
Agent-Logs-Url: https://github.com/CyberSecDef/NovelForge/sessions/ee7eaf41-4aa6-4e66-8ab9-e00dc4ad6d20 Co-authored-by: CyberSecDef <17597068+CyberSecDef@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes missing accessibility attributes on chapter rows that are inserted dynamically via “Add Before” / “Add After”, so screen readers can identify editable cells and action buttons consistently.
Changes:
- Added
buildNewChapterRowHtml()helper to centralize new-row markup for both insertion paths. - Ensured dynamically inserted rows include
role="textbox"andaria-labelon editable cells, plusaria-labelon action buttons and button groups.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function buildNewChapterRowHtml() { | ||
| return ( | ||
| "<tr>" + | ||
| "<td class='chapter-number'></td>" + | ||
| "<td><div class='editable-cell' contenteditable='true' data-field='title'>New Chapter</div></td>" + | ||
| "<td><div class='editable-cell' contenteditable='true' data-field='summary'>Enter chapter summary...</div></td>" + | ||
| "<td><div class='editable-cell' contenteditable='true' data-field='title' role='textbox' aria-label='Chapter title'>New Chapter</div></td>" + | ||
| "<td><div class='editable-cell' contenteditable='true' data-field='summary' role='textbox' aria-label='Chapter summary'>Enter chapter summary...</div></td>" + |
There was a problem hiding this comment.
buildNewChapterRowHtml() duplicates most of the markup already constructed in addChapterRow(), but with different escaping and ARIA-label conventions. To avoid the two templates drifting again (especially for accessibility attributes), consider extracting a single chapter-row builder that both addChapterRow() and the add-before/add-after handlers can use (e.g., parameterized by title/summary and optionally number).
| "<td><div class='editable-cell' contenteditable='true' data-field='title' role='textbox' aria-label='Chapter title'>New Chapter</div></td>" + | ||
| "<td><div class='editable-cell' contenteditable='true' data-field='summary' role='textbox' aria-label='Chapter summary'>Enter chapter summary...</div></td>" + | ||
| "<td class='text-center'>" + | ||
| "<div class='btn-group btn-group-sm me-1' role='group'>" + | ||
| "<button class='btn btn-outline-secondary btn-move-up' title='Move Up'><i class='bi bi-arrow-up'></i></button>" + | ||
| "<button class='btn btn-outline-secondary btn-move-down' title='Move Down'><i class='bi bi-arrow-down'></i></button>" + | ||
| "<div class='btn-group btn-group-sm me-1' role='group' aria-label='Reorder chapter'>" + | ||
| "<button class='btn btn-outline-secondary btn-move-up' title='Move Up' aria-label='Move chapter up'><i class='bi bi-arrow-up'></i></button>" + | ||
| "<button class='btn btn-outline-secondary btn-move-down' title='Move Down' aria-label='Move chapter down'><i class='bi bi-arrow-down'></i></button>" + | ||
| "</div>" + | ||
| "<div class='btn-group btn-group-sm me-1' role='group'>" + | ||
| "<button class='btn btn-outline-success btn-add-before' title='Add Before'><i class='bi bi-plus-circle'></i></button>" + | ||
| "<button class='btn btn-outline-success btn-add-after' title='Add After'><i class='bi bi-plus-circle'></i></button>" + | ||
| "<div class='btn-group btn-group-sm me-1' role='group' aria-label='Insert around chapter'>" + | ||
| "<button class='btn btn-outline-success btn-add-before' title='Add Before' aria-label='Add chapter before'><i class='bi bi-plus-circle'></i></button>" + |
There was a problem hiding this comment.
The new rows use generic aria-label values (e.g., "Chapter title"), while rows created via addChapterRow() use numbered labels (e.g., "Chapter 3 title"). Since renumberChapters() only updates the visible number, moving/inserting chapters can leave the existing numbered aria-labels incorrect. Consider updating renumberChapters() (or adding a helper it calls) to also recompute all chapter-related ARIA labels (cells, button groups, and buttons) based on the current index so screen readers get accurate, consistent labels.
Dynamically inserted chapter rows (via "Add Before"/"Add After") were missing
role="textbox",aria-labelon editable cells, andaria-labelon all action buttons — attributes present on template-rendered rows — leaving screen readers unable to identify cell purpose or button actions.Changes
static/js/script.jsbuildNewChapterRowHtml()helper, replacing the duplicated inline HTML strings in bothbtn-add-beforeandbtn-add-afterhandlersaddChapterRow()pattern:role="textbox"+aria-labelon title and summary editable cellsaria-labelon each button (move-up,move-down,add-before,add-after,delete-chapter)aria-labelon button group<div>elementsGeneric labels (e.g.
"Chapter title"rather than"Chapter 3 title") are used sincerenumberChapters()only updates visible text, notaria-labelvalues.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
api.openai.com/usr/bin/python python -m pytest tests/ -x -q --tb=short(dns block)/usr/bin/python python -m pytest tests/ -q --tb=short(dns block)/usr/bin/python python -m pytest tests/ --tb=short(dns block)If you need me to access, download, or install something from one of these locations, you can either: