Skip to content

Commit

Permalink
focus first input when opening authoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaskikutis committed Oct 25, 2023
1 parent 5c83e10 commit 85113d1
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,22 @@ export function AuthoringHeaderDirective(
scope.$apply();
};

// If correction set focus to the ednote to encourage user to fill it in
defer(() => {
if (scope.action === 'correct') {
elem.find('#ednote').focus();
} else {
elem.find('#slugline').focus();
const sorted = [...elem[0].querySelectorAll('input, textarea, [contenteditable]')]
.map((el) => {
return {
input: el,
order: parseInt(el.closest('[order]').getAttribute('order'), 10),
};
})
.sort((a, b) => a.order - b.order);

if (sorted.length > 0) {
sorted[0].input.focus();
}
}
});
},
Expand Down

0 comments on commit 85113d1

Please sign in to comment.