Skip to content

Commit b58c6bf

Browse files
kibanamachineangeles-mbelasticmachine
authored
[9.2] [SharedUX][A11y] Fix calendar event description field error text (elastic#240442) (elastic#240863)
# Backport This will backport the following commits from `main` to `9.2`: - [[SharedUX][A11y] Fix calendar event description field error text (elastic#240442)](elastic#240442) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Ángeles Martínez Barrio","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-10-27T16:25:31Z","message":"[SharedUX][A11y] Fix calendar event description field error text (elastic#240442)\n\nCloses https://github.com/elastic/kibana/issues/216992\n\n## Summary\n\n- Added explicit error message for users to better understand why the\nfield is in an error state: error only appears after the user interacts\nwith the field (either on change or on blur for keyboard navigation)\n- Added the `descriptionVisited` state initialized to false to avoid\nshowing the error on first modal render\n- Added basic field validation to avoid empty descriptions (spaces)\nbeing saved\n\n### Testing\n\n**Error behavior:**\nBefore:\n\n\nhttps://github.com/user-attachments/assets/6661c1fd-20ea-46ec-8483-590ba7f02549\n\nAfter:\n\n\nhttps://github.com/user-attachments/assets/33596ede-0370-4190-9d3b-1465709ea1a7\n\n**VoiceOver error announcement:**\nBefore:\n\n<img width=\"1075\" height=\"322\" alt=\"Screenshot 2025-10-24 at 12 57 12\"\nsrc=\"https://github.com/user-attachments/assets/683b214c-5d05-4c35-a169-609c44288fbf\"\n/>\n\nAfter:\n\n<img width=\"1020\" height=\"327\" alt=\"Screenshot 2025-10-24 at 12 56 10\"\nsrc=\"https://github.com/user-attachments/assets/bec8d439-8bcf-4620-8bd1-f73d3ed282a1\"\n/>\n\nCo-authored-by: Elastic Machine <[email protected]>","sha":"7e0dded80a6c4e4c4fe63ff4216682a7651946a8","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":[":ml","release_note:skip","Team:SharedUX","backport:version","a11y","v9.3.0","v9.2.1"],"title":"[SharedUX][A11y] Fix calendar event description field error text","number":240442,"url":"https://github.com/elastic/kibana/pull/240442","mergeCommit":{"message":"[SharedUX][A11y] Fix calendar event description field error text (elastic#240442)\n\nCloses https://github.com/elastic/kibana/issues/216992\n\n## Summary\n\n- Added explicit error message for users to better understand why the\nfield is in an error state: error only appears after the user interacts\nwith the field (either on change or on blur for keyboard navigation)\n- Added the `descriptionVisited` state initialized to false to avoid\nshowing the error on first modal render\n- Added basic field validation to avoid empty descriptions (spaces)\nbeing saved\n\n### Testing\n\n**Error behavior:**\nBefore:\n\n\nhttps://github.com/user-attachments/assets/6661c1fd-20ea-46ec-8483-590ba7f02549\n\nAfter:\n\n\nhttps://github.com/user-attachments/assets/33596ede-0370-4190-9d3b-1465709ea1a7\n\n**VoiceOver error announcement:**\nBefore:\n\n<img width=\"1075\" height=\"322\" alt=\"Screenshot 2025-10-24 at 12 57 12\"\nsrc=\"https://github.com/user-attachments/assets/683b214c-5d05-4c35-a169-609c44288fbf\"\n/>\n\nAfter:\n\n<img width=\"1020\" height=\"327\" alt=\"Screenshot 2025-10-24 at 12 56 10\"\nsrc=\"https://github.com/user-attachments/assets/bec8d439-8bcf-4620-8bd1-f73d3ed282a1\"\n/>\n\nCo-authored-by: Elastic Machine <[email protected]>","sha":"7e0dded80a6c4e4c4fe63ff4216682a7651946a8"}},"sourceBranch":"main","suggestedTargetBranches":["9.2"],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/240442","number":240442,"mergeCommit":{"message":"[SharedUX][A11y] Fix calendar event description field error text (elastic#240442)\n\nCloses https://github.com/elastic/kibana/issues/216992\n\n## Summary\n\n- Added explicit error message for users to better understand why the\nfield is in an error state: error only appears after the user interacts\nwith the field (either on change or on blur for keyboard navigation)\n- Added the `descriptionVisited` state initialized to false to avoid\nshowing the error on first modal render\n- Added basic field validation to avoid empty descriptions (spaces)\nbeing saved\n\n### Testing\n\n**Error behavior:**\nBefore:\n\n\nhttps://github.com/user-attachments/assets/6661c1fd-20ea-46ec-8483-590ba7f02549\n\nAfter:\n\n\nhttps://github.com/user-attachments/assets/33596ede-0370-4190-9d3b-1465709ea1a7\n\n**VoiceOver error announcement:**\nBefore:\n\n<img width=\"1075\" height=\"322\" alt=\"Screenshot 2025-10-24 at 12 57 12\"\nsrc=\"https://github.com/user-attachments/assets/683b214c-5d05-4c35-a169-609c44288fbf\"\n/>\n\nAfter:\n\n<img width=\"1020\" height=\"327\" alt=\"Screenshot 2025-10-24 at 12 56 10\"\nsrc=\"https://github.com/user-attachments/assets/bec8d439-8bcf-4620-8bd1-f73d3ed282a1\"\n/>\n\nCo-authored-by: Elastic Machine <[email protected]>","sha":"7e0dded80a6c4e4c4fe63ff4216682a7651946a8"}},{"branch":"9.2","label":"v9.2.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Ángeles Martínez Barrio <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
1 parent 5e24523 commit b58c6bf

File tree

1 file changed

+18
-3
lines changed
  • x-pack/platform/plugins/shared/ml/public/application/settings/calendars/edit/new_event_modal

1 file changed

+18
-3
lines changed

x-pack/platform/plugins/shared/ml/public/application/settings/calendars/edit/new_event_modal/new_event_modal.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export class NewEventModal extends Component {
5252
startDate,
5353
endDate,
5454
description: '',
55+
descriptionVisited: false,
5556
startDateString: startDate.format(TIME_FORMAT),
5657
endDateString: endDate.format(TIME_FORMAT),
5758
};
@@ -60,6 +61,13 @@ export class NewEventModal extends Component {
6061
onDescriptionChange = (e) => {
6162
this.setState({
6263
description: e.target.value,
64+
descriptionVisited: true,
65+
});
66+
};
67+
68+
onDescriptionBlur = () => {
69+
this.setState({
70+
descriptionVisited: true,
6371
});
6472
};
6573

@@ -260,7 +268,9 @@ export class NewEventModal extends Component {
260268

261269
render() {
262270
const { closeModal } = this.props;
263-
const { description } = this.state;
271+
const { description, descriptionVisited } = this.state;
272+
const isDescriptionInvalid = !description.trim();
273+
const isDescriptionInvalidVisible = isDescriptionInvalid && descriptionVisited;
264274
const modalTitleId = htmlIdGenerator()('modalTitle');
265275

266276
return (
@@ -291,11 +301,16 @@ export class NewEventModal extends Component {
291301
/>
292302
}
293303
fullWidth
304+
error={i18n.translate('xpack.ml.calendarsEdit.newEventModal.descriptionError', {
305+
defaultMessage: 'Description cannot be empty',
306+
})}
307+
isInvalid={isDescriptionInvalidVisible}
294308
>
295309
<EuiFieldText
296310
name="eventDescription"
311+
onBlur={this.onDescriptionBlur}
297312
onChange={this.onDescriptionChange}
298-
isInvalid={!description}
313+
isInvalid={isDescriptionInvalidVisible}
299314
fullWidth
300315
data-test-subj={'mlCalendarEventDescriptionInput'}
301316
/>
@@ -317,7 +332,7 @@ export class NewEventModal extends Component {
317332
<EuiButton
318333
onClick={this.handleAddEvent}
319334
fill
320-
disabled={!description}
335+
disabled={isDescriptionInvalid}
321336
data-test-subj={'mlCalendarAddEventButton'}
322337
>
323338
<FormattedMessage

0 commit comments

Comments
 (0)