File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -63,12 +63,16 @@ class AddTaskButton extends React.Component<Props, State> {
63
63
const { isDisabled, feedbackUrl, ...passThrough } = this . props ;
64
64
const { isTaskFormOpen, taskType, error } = this . state ;
65
65
66
+ // CSS selector for first form element
67
+ // Note: Modal throws an error if this fails to find an element!
68
+ const focusTargetSelector = '.task-modal input' ;
66
69
return (
67
70
< React . Fragment >
68
71
< AddTaskMenu isDisabled = { isDisabled } onMenuItemClick = { this . handleClickMenuItem } />
69
72
< Modal
70
73
className = "be-modal task-modal"
71
74
data-testid = "create-task-modal"
75
+ focusElementSelector = { focusTargetSelector }
72
76
isOpen = { isTaskFormOpen }
73
77
onRequestClose = { this . handleModalClose }
74
78
title = {
Original file line number Diff line number Diff line change @@ -24,6 +24,14 @@ describe('Create Task', () => {
24
24
} ) ;
25
25
} ) ;
26
26
27
+ context ( 'Task Modal' , ( ) => {
28
+ it ( 'autofocuses first input (assignees)' , ( ) => {
29
+ cy . contains ( l ( 'be.tasks.addTask' ) ) . click ( ) ;
30
+ cy . contains ( l ( 'be.tasks.addTask.approval' ) ) . click ( ) ;
31
+ cy . focused ( ) . should ( 'have.attr' , 'data-testid' , 'task-form-assignee-input' ) ;
32
+ } ) ;
33
+ } ) ;
34
+
27
35
context ( 'Task Form' , ( ) => {
28
36
beforeEach ( ( ) => {
29
37
cy . server ( ) ;
You can’t perform that action at this time.
0 commit comments