Skip to content

Commit 4ef3660

Browse files
authored
fix: Align styles between disabled input and select form controls (#3702)
1 parent 311693c commit 4ef3660

File tree

4 files changed

+87
-4
lines changed

4 files changed

+87
-4
lines changed

pages/button-trigger/permutations.page.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33
import * as React from 'react';
44

5+
import Box from '~components/box';
56
import ButtonTrigger, { ButtonTriggerProps } from '~components/internal/components/button-trigger';
67
import Option from '~components/internal/components/option';
78
import { OptionDefinition } from '~components/internal/components/option/interfaces';
@@ -23,6 +24,18 @@ const option2: OptionDefinition = {
2324
filteringTags: ['tag 1', 'tag 2'],
2425
};
2526

27+
const responsivePermutations = createPermutations<ButtonTriggerProps>([
28+
{
29+
disabled: [true, false],
30+
children: ['Long label to check the regression'],
31+
},
32+
{
33+
disabled: [false],
34+
readOnly: [true],
35+
children: ['Long label to check the regression'],
36+
},
37+
]);
38+
2639
/* eslint-disable react/jsx-key */
2740
const permutations = createPermutations<ButtonTriggerProps>([
2841
{
@@ -65,6 +78,20 @@ export default function ButtonTriggerPermutations() {
6578
<h1>ButtonTrigger permutations</h1>
6679
<ScreenshotArea>
6780
<PermutationsView permutations={permutations} render={permutation => <ButtonTrigger {...permutation} />} />
81+
<Box margin={{ top: 'm' }}>
82+
{/* Permutations to check that the width of the trigger doesn't change between states */}
83+
<PermutationsView
84+
permutations={responsivePermutations}
85+
render={permutation => (
86+
<div style={{ display: 'flex' }}>
87+
<div>
88+
<ButtonTrigger {...permutation} />
89+
</div>
90+
<div style={{ border: '1px solid' }}>Test</div>
91+
</div>
92+
)}
93+
/>
94+
</Box>
6895
</ScreenshotArea>
6996
</>
7097
);
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
import React from 'react';
4+
5+
import Input from '~components/input';
6+
import Select from '~components/select';
7+
import SpaceBetween from '~components/space-between';
8+
9+
import ScreenshotArea from '../utils/screenshot-area';
10+
11+
function Inputs() {
12+
return (
13+
<SpaceBetween size="xs">
14+
<div>
15+
<Input ariaLabel="input" placeholder="Enter something" value="" onChange={() => {}} />
16+
<Select placeholder="Enter something" selectedOption={null} onChange={() => {}} />
17+
</div>
18+
19+
<div>
20+
<Input ariaLabel="input" value="Something" onChange={() => {}} />
21+
<Select selectedOption={{ label: 'Label', value: 'value' }} onChange={() => {}} />
22+
</div>
23+
24+
<div>
25+
<Input ariaLabel="input" value="Something" readOnly={true} onChange={() => {}} />
26+
<Select selectedOption={{ label: 'Label', value: 'value' }} readOnly={true} onChange={() => {}} />
27+
</div>
28+
29+
<div>
30+
<Input ariaLabel="input" value="Something" disabled={true} onChange={() => {}} />
31+
<Select selectedOption={{ label: 'Label', value: 'value' }} disabled={true} onChange={() => {}} />
32+
</div>
33+
34+
<div>
35+
<Input ariaLabel="input" value="Something" readOnly={true} disabled={true} onChange={() => {}} />
36+
<Select
37+
selectedOption={{ label: 'Label', value: 'value' }}
38+
readOnly={true}
39+
disabled={true}
40+
onChange={() => {}}
41+
/>
42+
</div>
43+
</SpaceBetween>
44+
);
45+
}
46+
47+
export default function InputsPage() {
48+
return (
49+
<div style={{ padding: 10 }}>
50+
<h1>Inputs VS Selects demo</h1>
51+
<ScreenshotArea>
52+
<Inputs />
53+
</ScreenshotArea>
54+
</div>
55+
);
56+
}

src/button-dropdown/internal.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ const InternalButtonDropdown = React.forwardRef(
263263
styles['trigger-item'],
264264
styles['split-trigger'],
265265
styles[`variant-${variant}`],
266-
mainActionProps.disabled && styles.disabled,
267266
mainActionProps.loading && styles.loading
268267
)}
269268
// Close dropdown upon main action click unless event is cancelled.
@@ -287,7 +286,6 @@ const InternalButtonDropdown = React.forwardRef(
287286
styles['dropdown-trigger'],
288287
isVisualRefresh && styles['visual-refresh'],
289288
styles[`variant-${variant}`],
290-
baseTriggerProps.disabled && styles.disabled,
291289
baseTriggerProps.loading && styles.loading
292290
)}
293291
{...getAnalyticsMetadataAttribute(analyticsMetadata)}

src/internal/components/button-trigger/styles.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,15 @@ $padding-block-inner-filtering-token: 0px;
8484
}
8585

8686
&.disabled {
87-
@include styles.button-trigger-disabled-element;
87+
@include styles.form-disabled-element;
8888

8989
> .arrow {
9090
color: awsui.$color-text-button-inline-icon-disabled;
9191
}
9292

9393
&.in-filtering-token {
94+
// select in property filter has different border style
95+
@include styles.button-trigger-disabled-element;
9496
border-color: awsui.$color-border-control-disabled;
9597
}
9698

@@ -102,7 +104,7 @@ $padding-block-inner-filtering-token: 0px;
102104
// read-only in-filtering-token (i.e. for property filter readOnlyOperations)
103105
// should retain standard borders, only the icon changes
104106
&.readonly:not(&.disabled):not(&.in-filtering-token) {
105-
@include styles.button-trigger-readonly-element;
107+
@include styles.form-readonly-element;
106108
}
107109

108110
&:focus {

0 commit comments

Comments
 (0)