Skip to content

Commit 1cef50e

Browse files
committed
fix issues with disable
1 parent 839c018 commit 1cef50e

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/plugins/index_pattern_field_editor/public/components/field_format_editor/editors/duration/__snapshots__/duration.test.tsx.snap

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

src/plugins/index_pattern_field_editor/public/components/field_format_editor/editors/duration/duration.test.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,15 @@ describe('DurationFormatEditor', () => {
132132

133133
const labels = component.find(EuiSwitch);
134134
expect(labels.length).toEqual(2);
135-
expect(labels.get(0).props.label.props.defaultMessage).toEqual('Use short suffix');
136-
expect(labels.get(0).props.disabled).toEqual(false);
137-
expect(labels.get(1).props.label.props.defaultMessage).toEqual(
135+
const useShortSuffixSwitch = labels.get(0);
136+
137+
expect(useShortSuffixSwitch.props.label.props.defaultMessage).toEqual('Use short suffix');
138+
expect(useShortSuffixSwitch.props.disabled).toEqual(false);
139+
140+
const includeSpaceSwitch = labels.get(1);
141+
142+
expect(includeSpaceSwitch.props.disabled).toEqual(false);
143+
expect(includeSpaceSwitch.props.label.props.defaultMessage).toEqual(
138144
'Include space between suffix and value'
139145
);
140146

src/plugins/index_pattern_field_editor/public/components/field_format_editor/editors/duration/duration.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ export class DurationFormatEditor extends DefaultFormatEditor<
179179
onChange={(e) => {
180180
this.onChange({
181181
showSuffix: !formatParams.showSuffix,
182-
includeSpaceWithSuffix: !formatParams.showSuffix,
183182
});
184183
}}
185184
/>
@@ -204,7 +203,9 @@ export class DurationFormatEditor extends DefaultFormatEditor<
204203
</EuiFormRow>
205204
<EuiFormRow>
206205
<EuiSwitch
207-
disabled={!Boolean(formatParams.showSuffix)}
206+
disabled={
207+
!Boolean(formatParams.showSuffix) && !(format as DurationFormat).isHumanPrecise()
208+
}
208209
label={
209210
<FormattedMessage
210211
id="indexPatternFieldEditor.duration.includeSpace"

0 commit comments

Comments
 (0)