From 5f1367b14eb2caf17bc0b7877dbd6c9d08d4adeb Mon Sep 17 00:00:00 2001
From: Caroline Horn <549577+cchaos@users.noreply.github.com>
Date: Mon, 2 Mar 2020 16:51:29 -0500
Subject: [PATCH] [Advanced Settings] Fix a11y of unsaved indicator (#58511)
(#59071)
* [Advanced Settings] Fix a11y of unsaved indicator
- Reduced size of the indicator bar on the left
- Added icons with tooltips to indicated unsaved and invalid states
* Snaps
* Fix mobile view of bottom bar
---
.../management_app/advanced_settings.scss | 30 +-
.../field/__snapshots__/field.test.tsx.snap | 432 +++++++++++++++---
.../management_app/components/field/field.tsx | 29 +-
.../management_app/components/form/form.tsx | 90 ++--
4 files changed, 468 insertions(+), 113 deletions(-)
diff --git a/src/plugins/advanced_settings/public/management_app/advanced_settings.scss b/src/plugins/advanced_settings/public/management_app/advanced_settings.scss
index 016edb2817da8..66ae9cca3f83b 100644
--- a/src/plugins/advanced_settings/public/management_app/advanced_settings.scss
+++ b/src/plugins/advanced_settings/public/management_app/advanced_settings.scss
@@ -22,40 +22,42 @@
margin-top: $euiSize;
}
+ .mgtAdvancedSettings__fieldTitle {
+ padding-left: $euiSizeS;
+ margin-left: -$euiSizeS;
+ }
- padding-left: $euiSizeS;
- margin-left: -$euiSizeS;
- &--unsaved {
+ &--unsaved .mgtAdvancedSettings__fieldTitle {
// Simulates a left side border without shifting content
- box-shadow: -$euiSizeXS 0px $euiColorSecondary;
+ box-shadow: -$euiSizeXS 0px $euiColorWarning;
}
- &--invalid {
+ &--invalid .mgtAdvancedSettings__fieldTitle {
// Simulates a left side border without shifting content
box-shadow: -$euiSizeXS 0px $euiColorDanger;
}
- @include internetExplorerOnly() {
- min-height: 1px;
- }
- &Row {
- padding-left: $euiSizeS;
- }
@include internetExplorerOnly {
+ min-height: 1px;
+
&Row {
min-height: 1px;
}
}
}
+.mgtAdvancedSettings__fieldTitleUnsavedIcon {
+ margin-left: $euiSizeS;
+}
+
.mgtAdvancedSettingsForm__unsavedCount {
- @include euiBreakpoint('xs', 's') {
+ @include euiBreakpoint('xs') {
display: none;
}
}
-.mgtAdvancedSettingsForm__unsavedCountMessage{
+.mgtAdvancedSettingsForm__unsavedCountMessage {
// Simulates a left side border without shifting content
- box-shadow: -$euiSizeXS 0px $euiColorSecondary;
+ box-shadow: -$euiSizeXS 0px $euiColorWarning;
padding-left: $euiSizeS;
}
diff --git a/src/plugins/advanced_settings/public/management_app/components/field/__snapshots__/field.test.tsx.snap b/src/plugins/advanced_settings/public/management_app/components/field/__snapshots__/field.test.tsx.snap
index 2f4d806e60244..dba1678339f24 100644
--- a/src/plugins/advanced_settings/public/management_app/components/field/__snapshots__/field.test.tsx.snap
+++ b/src/plugins/advanced_settings/public/management_app/components/field/__snapshots__/field.test.tsx.snap
@@ -17,7 +17,12 @@ exports[`Field for array setting should render as read only if saving is disable
fullWidth={true}
title={
- Array test setting
+
+ Array test setting
+
+
}
@@ -84,7 +89,12 @@ exports[`Field for array setting should render as read only with help text if ov
fullWidth={true}
title={
- Array test setting
+
+ Array test setting
+
+
}
@@ -139,7 +149,11 @@ exports[`Field for array setting should render custom setting icon if it is cust
fullWidth={true}
title={
- Array test setting
+
+ Array test setting
+
+
}
>
@@ -195,7 +210,12 @@ exports[`Field for array setting should render default value if there is no user
fullWidth={true}
title={
- Array test setting
+
+ Array test setting
+
+
}
@@ -240,7 +260,11 @@ exports[`Field for array setting should render unsaved value if there are unsave
fullWidth={true}
title={
- Array test setting
+
+ Array test setting
+
+
}
>
@@ -330,7 +361,12 @@ exports[`Field for array setting should render user value if there is user value
fullWidth={true}
title={
- Array test setting
+
+ Array test setting
+
+
}
@@ -392,7 +428,12 @@ exports[`Field for boolean setting should render as read only if saving is disab
fullWidth={true}
title={
- Boolean test setting
+
+ Boolean test setting
+
+
}
@@ -465,7 +506,12 @@ exports[`Field for boolean setting should render as read only with help text if
fullWidth={true}
title={
- Boolean test setting
+
+ Boolean test setting
+
+
}
@@ -526,7 +572,11 @@ exports[`Field for boolean setting should render custom setting icon if it is cu
fullWidth={true}
title={
- Boolean test setting
+
+ Boolean test setting
+
+
}
>
@@ -588,7 +639,12 @@ exports[`Field for boolean setting should render default value if there is no us
fullWidth={true}
title={
- Boolean test setting
+
+ Boolean test setting
+
+
}
@@ -639,7 +695,11 @@ exports[`Field for boolean setting should render unsaved value if there are unsa
fullWidth={true}
title={
- Boolean test setting
+
+ Boolean test setting
+
+
}
>
@@ -731,7 +798,12 @@ exports[`Field for boolean setting should render user value if there is user val
fullWidth={true}
title={
- Boolean test setting
+
+ Boolean test setting
+
+
}
@@ -799,7 +871,12 @@ exports[`Field for image setting should render as read only if saving is disable
fullWidth={true}
title={
- Image test setting
+
+ Image test setting
+
+
}
@@ -868,7 +945,12 @@ exports[`Field for image setting should render as read only with help text if ov
fullWidth={true}
title={
- Image test setting
+
+ Image test setting
+
+
}
@@ -921,7 +1003,11 @@ exports[`Field for image setting should render custom setting icon if it is cust
fullWidth={true}
title={
- Image test setting
+
+ Image test setting
+
+
}
>
@@ -979,7 +1066,12 @@ exports[`Field for image setting should render default value if there is no user
fullWidth={true}
title={
- Image test setting
+
+ Image test setting
+
+
}
@@ -1026,7 +1118,11 @@ exports[`Field for image setting should render unsaved value if there are unsave
fullWidth={true}
title={
- Image test setting
+
+ Image test setting
+
+
}
>
@@ -1113,7 +1216,12 @@ exports[`Field for image setting should render user value if there is user value
fullWidth={true}
title={
- Image test setting
+
+ Image test setting
+
+
}
@@ -1211,7 +1319,12 @@ exports[`Field for json setting should render as read only if saving is disabled
fullWidth={true}
title={
- Json test setting
+
+ Json test setting
+
+
}
@@ -1302,7 +1415,12 @@ exports[`Field for json setting should render as read only with help text if ove
fullWidth={true}
title={
- Json test setting
+
+ Json test setting
+
+
}
@@ -1378,7 +1496,11 @@ exports[`Field for json setting should render custom setting icon if it is custo
fullWidth={true}
title={
- Json test setting
+
+ Json test setting
+
+
}
>
@@ -1480,7 +1603,12 @@ exports[`Field for json setting should render default value if there is no user
fullWidth={true}
title={
- Json test setting
+
+ Json test setting
+
+
}
@@ -1563,7 +1691,11 @@ exports[`Field for json setting should render unsaved value if there are unsaved
fullWidth={true}
title={
- Json test setting
+
+ Json test setting
+
+
}
>
@@ -1677,7 +1816,12 @@ exports[`Field for json setting should render user value if there is user value
fullWidth={true}
title={
- Json test setting
+
+ Json test setting
+
+
}
@@ -1760,7 +1904,12 @@ exports[`Field for markdown setting should render as read only if saving is disa
fullWidth={true}
title={
- Markdown test setting
+
+ Markdown test setting
+
+
}
@@ -1848,7 +1997,12 @@ exports[`Field for markdown setting should render as read only with help text if
fullWidth={true}
title={
- Markdown test setting
+
+ Markdown test setting
+
+
}
@@ -1924,7 +2078,11 @@ exports[`Field for markdown setting should render custom setting icon if it is c
fullWidth={true}
title={
- Markdown test setting
+
+ Markdown test setting
+
+
}
>
@@ -2001,7 +2160,12 @@ exports[`Field for markdown setting should render default value if there is no u
fullWidth={true}
title={
- Markdown test setting
+
+ Markdown test setting
+
+
}
@@ -2067,7 +2231,11 @@ exports[`Field for markdown setting should render unsaved value if there are uns
fullWidth={true}
title={
- Markdown test setting
+
+ Markdown test setting
+
+
}
>
@@ -2174,7 +2349,12 @@ exports[`Field for markdown setting should render user value if there is user va
fullWidth={true}
title={
- Markdown test setting
+
+ Markdown test setting
+
+
}
@@ -2257,7 +2437,12 @@ exports[`Field for number setting should render as read only if saving is disabl
fullWidth={true}
title={
- Number test setting
+
+ Number test setting
+
+
}
@@ -2324,7 +2509,12 @@ exports[`Field for number setting should render as read only with help text if o
fullWidth={true}
title={
- Number test setting
+
+ Number test setting
+
+
}
@@ -2379,7 +2569,11 @@ exports[`Field for number setting should render custom setting icon if it is cus
fullWidth={true}
title={
- Number test setting
+
+ Number test setting
+
+
}
>
@@ -2435,7 +2630,12 @@ exports[`Field for number setting should render default value if there is no use
fullWidth={true}
title={
- Number test setting
+
+ Number test setting
+
+
}
@@ -2480,7 +2680,11 @@ exports[`Field for number setting should render unsaved value if there are unsav
fullWidth={true}
title={
- Number test setting
+
+ Number test setting
+
+
}
>
@@ -2566,7 +2777,12 @@ exports[`Field for number setting should render user value if there is user valu
fullWidth={true}
title={
- Number test setting
+
+ Number test setting
+
+
}
@@ -2628,7 +2844,12 @@ exports[`Field for select setting should render as read only if saving is disabl
fullWidth={true}
title={
- Select test setting
+
+ Select test setting
+
+
}
@@ -2711,7 +2932,12 @@ exports[`Field for select setting should render as read only with help text if o
fullWidth={true}
title={
- Select test setting
+
+ Select test setting
+
+
}
@@ -2782,7 +3008,11 @@ exports[`Field for select setting should render custom setting icon if it is cus
fullWidth={true}
title={
- Select test setting
+
+ Select test setting
+
+
}
>
@@ -2854,7 +3085,12 @@ exports[`Field for select setting should render default value if there is no use
fullWidth={true}
title={
- Select test setting
+
+ Select test setting
+
+
}
@@ -2915,7 +3151,11 @@ exports[`Field for select setting should render unsaved value if there are unsav
fullWidth={true}
title={
- Select test setting
+
+ Select test setting
+
+
}
>
@@ -3017,7 +3264,12 @@ exports[`Field for select setting should render user value if there is user valu
fullWidth={true}
title={
- Select test setting
+
+ Select test setting
+
+
}
@@ -3095,7 +3347,12 @@ exports[`Field for string setting should render as read only if saving is disabl
fullWidth={true}
title={
- String test setting
+
+ String test setting
+
+
}
@@ -3162,7 +3419,12 @@ exports[`Field for string setting should render as read only with help text if o
fullWidth={true}
title={
- String test setting
+
+ String test setting
+
+
}
@@ -3217,7 +3479,11 @@ exports[`Field for string setting should render custom setting icon if it is cus
fullWidth={true}
title={
- String test setting
+
+ String test setting
+
+
}
>
@@ -3273,7 +3540,12 @@ exports[`Field for string setting should render default value if there is no use
fullWidth={true}
title={
- String test setting
+
+ String test setting
+
+
}
@@ -3318,7 +3590,11 @@ exports[`Field for string setting should render unsaved value if there are unsav
fullWidth={true}
title={
- String test setting
+
+ String test setting
+
+
}
>
@@ -3404,7 +3687,12 @@ exports[`Field for string setting should render user value if there is user valu
fullWidth={true}
title={
- String test setting
+
+ String test setting
+
+
}
@@ -3466,7 +3754,12 @@ exports[`Field for stringWithValidation setting should render as read only if sa
fullWidth={true}
title={
- String test validation setting
+
+ String test validation setting
+
+
}
@@ -3533,7 +3826,12 @@ exports[`Field for stringWithValidation setting should render as read only with
fullWidth={true}
title={
- String test validation setting
+
+ String test validation setting
+
+
}
@@ -3588,7 +3886,11 @@ exports[`Field for stringWithValidation setting should render custom setting ico
fullWidth={true}
title={
- String test validation setting
+
+ String test validation setting
+
+
}
>
@@ -3644,7 +3947,12 @@ exports[`Field for stringWithValidation setting should render default value if t
fullWidth={true}
title={
- String test validation setting
+
+ String test validation setting
+
+
}
@@ -3689,7 +3997,11 @@ exports[`Field for stringWithValidation setting should render unsaved value if t
fullWidth={true}
title={
- String test validation setting
+
+ String test validation setting
+
+
}
>
@@ -3775,7 +4094,12 @@ exports[`Field for stringWithValidation setting should render user value if ther
fullWidth={true}
title={
- String test validation setting
+
+ String test validation setting
+
+
}
diff --git a/src/plugins/advanced_settings/public/management_app/components/field/field.tsx b/src/plugins/advanced_settings/public/management_app/components/field/field.tsx
index d9c3752d1c0a5..18a1a365709d1 100644
--- a/src/plugins/advanced_settings/public/management_app/components/field/field.tsx
+++ b/src/plugins/advanced_settings/public/management_app/components/field/field.tsx
@@ -450,9 +450,24 @@ export class Field extends PureComponent {
}
renderTitle(setting: FieldSetting) {
+ const { unsavedChanges } = this.props;
+ const isInvalid = unsavedChanges?.isInvalid;
+
+ const unsavedIconLabel = unsavedChanges
+ ? isInvalid
+ ? i18n.translate('advancedSettings.field.invalidIconLabel', {
+ defaultMessage: 'Invalid',
+ })
+ : i18n.translate('advancedSettings.field.unsavedIconLabel', {
+ defaultMessage: 'Unsaved',
+ })
+ : undefined;
+
return (
- {setting.displayName || setting.name}
+
+ {setting.displayName || setting.name}
+
{setting.isCustom ? (
{
) : (
''
)}
+
+ {unsavedChanges ? (
+
+ ) : (
+ ''
+ )}
);
}
diff --git a/src/plugins/advanced_settings/public/management_app/components/form/form.tsx b/src/plugins/advanced_settings/public/management_app/components/form/form.tsx
index ef433dd990d33..c859e8fdd7136 100644
--- a/src/plugins/advanced_settings/public/management_app/components/form/form.tsx
+++ b/src/plugins/advanced_settings/public/management_app/components/form/form.tsx
@@ -331,54 +331,56 @@ export class Form extends PureComponent {
});
return (
-
+
{this.renderCountOfUnsaved()}
+
-
-
-
- {i18n.translate('advancedSettings.form.cancelButtonLabel', {
- defaultMessage: 'Cancel changes',
- })}
-
-
-
-
-
- {i18n.translate('advancedSettings.form.saveButtonLabel', {
- defaultMessage: 'Save changes',
- })}
-
-
-
-
+
+ {i18n.translate('advancedSettings.form.cancelButtonLabel', {
+ defaultMessage: 'Cancel changes',
+ })}
+
+
+
+
+
+ {i18n.translate('advancedSettings.form.saveButtonLabel', {
+ defaultMessage: 'Save changes',
+ })}
+
+