Skip to content

Commit bf9055e

Browse files
committed
ENH Use button element for delete button
1 parent 8977b54 commit bf9055e

3 files changed

Lines changed: 13 additions & 15 deletions

File tree

client/dist/js/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/src/components/LinkPicker/LinkPickerTitle.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,6 @@ const LinkPickerTitle = ({
144144
</small>
145145
)}
146146
</div>
147-
{(canDelete && !readonly && !disabled) &&
148-
// This is a <span> rather than a <Button> because we're inside a <Button> and
149-
// trigger an error when you attempt to nest a <Button> inside a <Button>.
150-
<span
151-
aria-label={deleteText}
152-
role="button"
153-
tabIndex="0"
154-
className="link-picker__delete btn btn-link"
155-
onKeyDown={handleDeleteKeyDown}
156-
onClick={stopPropagation(() => !loading ? onDelete(id) : null)}
157-
>{deleteText}</span>
158-
}
159147
</Button>
160148
{ (isMulti && !readonly && !disabled) && <div className="link-picker__drag-handle"
161149
{...attributes}
@@ -170,6 +158,17 @@ const LinkPickerTitle = ({
170158
focusable="false"
171159
></i>
172160
</div> }
161+
{(canDelete && !readonly && !disabled) &&
162+
// Intentionally using a regular button element rather than a Button react component
163+
// so that we do not end up with unwanted extra css classes
164+
<button
165+
aria-label={deleteText}
166+
tabIndex="0"
167+
className="link-picker__delete btn btn-link"
168+
onKeyDown={handleDeleteKeyDown}
169+
onClick={stopPropagation(() => !loading ? onDelete(id) : null)}
170+
>{deleteText}</button>
171+
}
173172
</Tag>
174173
};
175174

tests/behat/features/accessibility-linkfield.feature

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ Feature: Accessibility Tests
120120
And I should see "External Link" in the "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__link--is-last" element
121121
When I press the "Tab" key globally
122122
When I press the "Tab" key globally
123-
When I press the "Tab" key globally
124123
Then the active element should be "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__drag-handle"
125124
Then I press the "Enter" key globally
126125
And I press the "Down" key globally
@@ -132,7 +131,7 @@ Feature: Accessibility Tests
132131

133132
# Test user can delete the link
134133

135-
Then I press the "Shift-Tab" key globally
134+
Then I press the "Tab" key globally
136135
Then the active element should be "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__link:nth-of-type(3) .link-picker__delete"
137136
And I press the "Enter" key and confirm the dialog
138137
And I wait for 3 seconds

0 commit comments

Comments
 (0)