Skip to content

Commit

Permalink
WIP: Rewrite to use listbox role
Browse files Browse the repository at this point in the history
The listbox role isn't as good a fit with the note list's functionality
(particularly for more complicated list items). However, Windows
Narrator reads nothing with the 'grid' role. (Perhaps it was incorrectly
applied?)
  • Loading branch information
personalizedrefrigerator committed Aug 28, 2024
1 parent d547ee9 commit e7ddcf1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
23 changes: 6 additions & 17 deletions packages/app-desktop/gui/NoteList/NoteList2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import useDragAndDrop from './utils/useDragAndDrop';
import { itemIsInTrash } from '@joplin/lib/services/trash';
import getEmptyFolderMessage from '@joplin/lib/components/shared/NoteList/getEmptyFolderMessage';
import Folder from '@joplin/lib/models/Folder';
import { _ } from '@joplin/lib/locale';
const { connect } = require('react-redux');

const commands = {
Expand Down Expand Up @@ -202,26 +203,14 @@ const NoteList = (props: Props) => {

if (!props.notes.length) return { notes: rows, renderedSelectedItem };

const firstRowIndex = Math.floor(startNoteIndex / itemsPerLine);
let currentRow: JSX.Element[] = [];

const finalizeRow = () => {
if (currentRow.length === 0) {
return;
}

// Rows are 1-indexed
const rowIndex = firstRowIndex + rows.length + 1;
rows.push(
<div
key={`row-${rowIndex}`}
role='row'
className='row'
aria-rowindex={rowIndex}
>
{currentRow}
</div>,
);
rows.push(...currentRow);
currentRow = [];
};

Expand Down Expand Up @@ -300,9 +289,9 @@ const NoteList = (props: Props) => {

return (
<div
role='grid'
aria-colcount={itemsPerLine}
aria-rowcount={totalLineCount}
role='listbox'
aria-label={_('Notes')}
aria-setsize={notes.length}
aria-multiselectable={true}
// Ensure that the note list can be focused, even if no selected
// items are visible.
Expand All @@ -317,7 +306,7 @@ const NoteList = (props: Props) => {
>
{renderEmptyList()}
{renderFiller('top', topFillerStyle)}
<div className='notes note-list-grid' role='rowgroup' style={notesStyle}>
<div className='notes note-list-grid' role='presentation' style={notesStyle}>
{notes}
</div>
{renderFiller('bottom', bottomFillerStyle)}
Expand Down
7 changes: 0 additions & 7 deletions packages/app-desktop/gui/NoteList/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
}
}

.note-list-grid {
> .row {
display: flex;
flex-direction: row;
}
}

.note-list-item {
display: flex;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/app-desktop/gui/NoteListItem/NoteListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ const NoteListItem = (props: NoteItemProps, ref: LegacyRef<HTMLDivElement>) => {
onDragOver={props.onDragOver}

aria-selected={props.isSelected}
role='gridcell'
aria-posinset={1 + props.index}
role='option'
>
<div className="dragcursor" style={dragCursorStyle}></div>
</div>;
Expand Down

0 comments on commit e7ddcf1

Please sign in to comment.