Skip to content

Commit 30865c0

Browse files
stephanielearytmccanna
authored andcommitted
LP2101884 MARC Rich Editor subfield tabbing order
Changes the MARC rich editor keyboard navigation behavior so that either the right or left arrows can be used to move from grouped subfield focus (with all three inputs highlighted at once) into the subfield for editing. Also moves focus into the subfield value rather than the code. Additionally, changes the tabindex of the currently focused subfield group to -1 so that the group is not part of the tabbing order when moving out of the subfield inputs (in either direction). That is, tabbing out of the subfield group goes directly to the next or previous group rather than the current one. Release-note: Edit MARC subfield value in focused group with right or left arrow; do not focus on current group when tabbing into or out of subfield inputs Signed-off-by: Stephanie Leary <[email protected]> Signed-off-by: Ruth Frasur Davis <[email protected]> Signed-off-by: Terran McCanna <[email protected]>
1 parent 21f7ddd commit 30865c0

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

Open-ILS/src/eg2/src/app/staff/share/marc-edit/editable-content.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<ng-container *ngIf="!bigText">
3434

3535
<eg-combobox #MARCCombo *ngIf="suggest"
36+
trigger="click"
3637
[domId]="domId"
3738
[moreClasses]="'fw-bold form-control-sm type-'+fieldType"
3839
tabindex="{{tabindex}}"

Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor-context.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -439,24 +439,20 @@ export class MarcEditContext {
439439
this.insertSubfield(field, newSf);
440440
}
441441

442-
// Focus the requested subfield by its position. If its
443-
// position is less than zero, focus the field's tag instead.
442+
// Focus the requested subfield by its position.
444443
focusSubfield(field: MarcField, position: number, group?: boolean) {
445-
446-
const focus: FieldFocusRequest = {fieldId: field.fieldId, target: 'tag'};
447-
448-
if (position >= 0) {
449-
// Focus the code instead of the value, because attempting to
450-
// focus an empty (editable) div results in nothing getting focus.
451-
focus.target = 'sfc';
452-
focus.sfOffset = position;
453-
}
444+
// console.debug("focusSubfield()", field, position, group);
445+
const focus: FieldFocusRequest = {fieldId: field.fieldId, target: 'sfv'};
454446

455447
if (group) {
456448
focus.target = 'group';
457-
focus.sfOffset = position;
449+
} else if (position < 0) {
450+
// Focus the code instead of the value
451+
focus.target = 'sfc';
458452
}
459453

454+
focus.sfOffset = position;
455+
460456
this.requestFieldFocus(focus);
461457
}
462458

Open-ILS/src/eg2/src/app/staff/share/marc-edit/rich-editor.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ <h3 i18n>Keyboard Shortcuts</h3>
150150
<li i18n>Copy Current Row Above: Ctrl+Up</li>
151151
<li i18n>Copy Current Row Below: Ctrl+Down</li>
152152
<li i18n>Add Subfield: Ctrl+D or Ctrl+I</li>
153-
<li i18n>Edit Subfield (when grouped): Right Arrow</li>
153+
<li i18n>Edit Subfield (when grouped): Left or Right Arrow</li>
154154
<li i18n>Remove Row: Ctrl+Del</li>
155155
<li i18n>Remove Subfield: Shift+Del</li>
156156
<li i18n>Open Suggestions: Ctrl+Shift+Down</li>
@@ -318,10 +318,10 @@ <h3 i18n>Keyboard Shortcuts</h3>
318318
'full-width': subfield[1].length > 100 || context.isFullWidth(field.tag, subfield[0]),
319319
'last': last
320320
}"
321-
tabindex="0"
322-
[id]="'subfield-{{subfield[2]}}'"
321+
[tabindex]="getSubfieldTabindex(field, subfield)"
322+
[id]="getSubfieldDomId(field, subfield)"
323323
(keydown)="onKeyDown($event, field, subfield)"
324-
attr.aria-description="Press right arrow to edit."
324+
[attr.aria-description]="'Press right or left arrow to edit.'"
325325
i18n-aria-label i18n-aria-description>
326326
<ng-container #subfieldContent
327327
*ngTemplateOutlet="subfieldChunk;context:{field:field,subfield:subfield,tabIndex:context.subfieldHasFocus(field, subfield) ? 0 : -1}">

Open-ILS/src/eg2/src/app/staff/share/marc-edit/rich-editor.component.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ export class MarcRichEditorComponent implements OnInit {
213213

214214
onKeyDown(evt: KeyboardEvent, field: MarcField, subfield?: MarcSubfield) {
215215
switch (evt.key) {
216+
case 'ArrowLeft':
216217
case 'ArrowRight':
217218
// console.debug("ArrowRight: ", evt, field, subfield);
218219
let el = evt.target as HTMLElement;
@@ -349,6 +350,18 @@ export class MarcRichEditorComponent implements OnInit {
349350
evt.stopPropagation();
350351
}
351352

353+
getSubfieldDomId(field, subfield) {
354+
return 'subfield-' + field.tag+subfield[0] + '-' + subfield[2];
355+
}
356+
357+
getSubfieldTabindex(field, subfield) {
358+
const subfieldGroupElement = document.getElementById(this.getSubfieldDomId(field, subfield)) as HTMLElement;
359+
if (subfieldGroupElement?.contains(document.activeElement)) {
360+
return -1;
361+
}
362+
return 0;
363+
}
364+
352365
focusSubfieldGroup(field: MarcField, subfield: MarcSubfield) {
353366
// set lastFocused to subfield group for undo/redo purposes,
354367
// but do not emit a focus request

0 commit comments

Comments
 (0)