[8.x] [ES|QL] Fixes the accessibility issue of the run button (#215277) (#215435)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ES|QL] Fixes the accessibility issue of the run button
(#215277)](https://github.com/elastic/kibana/pull/215277)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Stratoula
Kalafateli","email":"efstratia.kalafateli@elastic.co"},"sourceCommit":{"committedDate":"2025-03-21T06:46:02Z","message":"[ES|QL]
Fixes the accessibility issue of the run button (#215277)\n\n##
Summary\n\nCloses
https://github.com/elastic/kibana/issues/214540\n\nSeparates the tooltip
label with the aria label for accessibility\nreasons\n\n<img
width=\"428\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/7aef7e8f-dc1d-4fce-ae05-cf6e215480af\"\n/>","sha":"6cd920c8e07b20d3d5060aa51694ec0ae9d7c197","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Feature:ES|QL","Team:ESQL","backport:version","v9.1.0","v8.19.0"],"title":"[ES|QL]
Fixes the accessibility issue of the run
button","number":215277,"url":"https://github.com/elastic/kibana/pull/215277","mergeCommit":{"message":"[ES|QL]
Fixes the accessibility issue of the run button (#215277)\n\n##
Summary\n\nCloses
https://github.com/elastic/kibana/issues/214540\n\nSeparates the tooltip
label with the aria label for accessibility\nreasons\n\n<img
width=\"428\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/7aef7e8f-dc1d-4fce-ae05-cf6e215480af\"\n/>","sha":"6cd920c8e07b20d3d5060aa51694ec0ae9d7c197"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/215277","number":215277,"mergeCommit":{"message":"[ES|QL]
Fixes the accessibility issue of the run button (#215277)\n\n##
Summary\n\nCloses
https://github.com/elastic/kibana/issues/214540\n\nSeparates the tooltip
label with the aria label for accessibility\nreasons\n\n<img
width=\"428\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/7aef7e8f-dc1d-4fce-ae05-cf6e215480af\"\n/>","sha":"6cd920c8e07b20d3d5060aa51694ec0ae9d7c197"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
This commit is contained in:
Kibana Machine 2025-03-21 09:41:48 +01:00 committed by GitHub
parent c828ff8696
commit d7d4bfd78f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -62,6 +62,7 @@ import './query_bar.scss';
const isMac = navigator.platform.toLowerCase().indexOf('mac') >= 0; const isMac = navigator.platform.toLowerCase().indexOf('mac') >= 0;
const COMMAND_KEY = isMac ? '⌘' : 'CTRL'; const COMMAND_KEY = isMac ? '⌘' : 'CTRL';
const textBasedRunShortcut = `${COMMAND_KEY} + Enter`;
export const strings = { export const strings = {
getNeedsUpdatingLabel: () => getNeedsUpdatingLabel: () =>
@ -88,6 +89,11 @@ export const strings = {
i18n.translate('unifiedSearch.queryBarTopRow.submitButton.run', { i18n.translate('unifiedSearch.queryBarTopRow.submitButton.run', {
defaultMessage: 'Run query', defaultMessage: 'Run query',
}), }),
getRunQueryShortcutLabel: () =>
i18n.translate('unifiedSearch.queryBarTopRow.submitButton.shortcutLabel', {
defaultMessage: `(shortcut {textBasedRunShortcut})`,
values: { textBasedRunShortcut },
}),
getRunButtonLabel: () => getRunButtonLabel: () =>
i18n.translate('unifiedSearch.queryBarTopRow.submitButton.runButton', { i18n.translate('unifiedSearch.queryBarTopRow.submitButton.runButton', {
defaultMessage: 'Run', defaultMessage: 'Run',
@ -565,9 +571,11 @@ export const QueryBarTopRow = React.memo(
if (!shouldRenderUpdatebutton() && !shouldRenderDatePicker()) { if (!shouldRenderUpdatebutton() && !shouldRenderDatePicker()) {
return null; return null;
} }
const textBasedRunShortcut = `${COMMAND_KEY} + Enter`;
const buttonLabelUpdate = strings.getNeedsUpdatingLabel();
const buttonLabelRefresh = Boolean(isQueryLangSelected) const buttonLabelRefresh = Boolean(isQueryLangSelected)
? `${strings.getRunQueryLabel()} ${strings.getRunQueryShortcutLabel()}`
: strings.getRefreshQueryLabel();
const buttonLabelUpdate = strings.getNeedsUpdatingLabel();
const tooltipText = Boolean(isQueryLangSelected)
? textBasedRunShortcut ? textBasedRunShortcut
: strings.getRefreshQueryLabel(); : strings.getRefreshQueryLabel();
const buttonLabelRun = textBasedRunShortcut; const buttonLabelRun = textBasedRunShortcut;
@ -598,7 +606,7 @@ export const QueryBarTopRow = React.memo(
needsUpdate={props.isDirty} needsUpdate={props.isDirty}
data-test-subj="querySubmitButton" data-test-subj="querySubmitButton"
toolTipProps={{ toolTipProps={{
content: props.isDirty ? tooltipDirty : buttonLabelRefresh, content: props.isDirty ? tooltipDirty : tooltipText,
delay: 'long', delay: 'long',
position: 'bottom', position: 'bottom',
}} }}