Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SelectControl: Fix disabled styles #63266

Merged
merged 4 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- `UnitControl`: Fix an issue where keyboard shortcuts unintentionally shift focus on Windows OS. ([#62988](https://github.com/WordPress/gutenberg/pull/62988))
- Fix inaccessibly disabled `Button`s ([#62306](https://github.com/WordPress/gutenberg/pull/62306)).
- `TimePicker`: Fix time zone overflow ([#63209](https://github.com/WordPress/gutenberg/pull/63209)).
- `SelectControl`: Fix disabled styles ([#63266](https://github.com/WordPress/gutenberg/pull/63266)).

### Internal

Expand Down
7 changes: 3 additions & 4 deletions packages/components/src/select-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import { forwardRef } from '@wordpress/element';
* Internal dependencies
*/
import BaseControl from '../base-control';
import InputBase from '../input-control/input-base';
import { Select } from './styles/select-control-styles';
import { Select, StyledInputBase } from './styles/select-control-styles';
import type { WordPressComponentProps } from '../context';
import type { SelectControlProps } from './types';
import SelectControlChevronDown from './chevron-down';
Expand Down Expand Up @@ -82,7 +81,7 @@ function UnforwardedSelectControl(
id={ id }
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
>
<InputBase
<StyledInputBase
className={ classes }
disabled={ disabled }
hideLabelFromVision={ hideLabelFromVision }
Expand Down Expand Up @@ -127,7 +126,7 @@ function UnforwardedSelectControl(
);
} ) }
</Select>
</InputBase>
</StyledInputBase>
</BaseControl>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { space } from '../../utils/space';
import type { SelectControlProps } from '../types';
import InputControlSuffixWrapper from '../../input-control/input-suffix-wrapper';
import { fontSizeStyles } from '../../input-control/styles/input-control-styles';
import InputBase from '../../input-control/input-base';

interface SelectProps
extends Pick<
Expand All @@ -28,11 +29,19 @@ const disabledStyles = ( { disabled }: SelectProps ) => {
return '';
}

return css( {
color: COLORS.ui.textDisabled,
} );
return css`
color: ${ COLORS.ui.textDisabled };
cursor: default;
`;
};

export const StyledInputBase = styled( InputBase )`
color: ${ COLORS.theme.foreground };
cursor: pointer;

${ disabledStyles }
`;

const sizeStyles = ( {
__next40pxDefaultSize,
multiple,
Expand Down Expand Up @@ -128,17 +137,15 @@ export const Select = styled.select< SelectProps >`
box-sizing: border-box;
border: none;
box-shadow: none !important;
color: ${ COLORS.gray[ 900 ] };
cursor: inherit;
display: block;
font-family: inherit;
margin: 0;
width: 100%;
max-width: none;
cursor: pointer;
white-space: nowrap;
text-overflow: ellipsis;

${ disabledStyles };
${ fontSizeStyles };
${ sizeStyles };
${ sizePaddings };
Expand All @@ -149,6 +156,10 @@ export const Select = styled.select< SelectProps >`
export const DownArrowWrapper = styled.div`
margin-inline-end: ${ space( -1 ) }; // optically adjust the icon
line-height: 0;

path {
fill: currentColor;
}
`;

export const InputControlSuffixWrapperWithClickThrough = styled(
Expand Down
Loading