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

Chore: visually hide labels in the create project form #7015

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,21 @@ export const StyledPopover = styled(Popover)(({ theme }) => ({
},
}));

export const StyledTextField = styled(TextField)(({ theme }) => ({
const visuallyHiddenStyles = {
border: 0,
clip: 'rect(0 0 0 0)',
height: 'auto',
margin: 0,
overflow: 'hidden',
padding: 0,
position: 'absolute',
width: '1px',
whiteSpace: 'nowrap',
};

export const StyledDropdownSearch = styled(TextField, {
shouldForwardProp: (prop) => prop !== 'hideLabel',
})<{ hideLabel?: boolean }>(({ theme, hideLabel }) => ({
'& .MuiInputBase-root': {
padding: theme.spacing(0, 1.5),
borderRadius: `${theme.shape.borderRadiusMedium}px`,
Expand All @@ -36,8 +50,16 @@ export const StyledTextField = styled(TextField)(({ theme }) => ({
padding: theme.spacing(0.75, 0),
fontSize: theme.typography.body2.fontSize,
},

...(hideLabel
? {
label: visuallyHiddenStyles,

'fieldset > legend > span': visuallyHiddenStyles,
}
: {}),
}));

export const TableSearchInput = styled(StyledTextField)(({ theme }) => ({
export const TableSearchInput = styled(StyledDropdownSearch)(({ theme }) => ({
maxWidth: '30ch',
}));
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
StyledDropdown,
StyledListItem,
StyledPopover,
StyledTextField,
StyledDropdownSearch,
TableSearchInput,
} from './SelectionButton.styles';
import { ChangeRequestTable } from './ChangeRequestTable';
Expand Down Expand Up @@ -152,12 +152,13 @@ const CombinedSelect: FC<CombinedSelectProps> = ({
}}
>
<StyledDropdown>
<StyledTextField
<StyledDropdownSearch
variant='outlined'
size='small'
value={searchText}
onChange={(event) => setSearchText(event.target.value)}
label={search.label}
hideLabel
placeholder={search.placeholder}
autoFocus
InputProps={{
Expand Down Expand Up @@ -399,6 +400,7 @@ export const TableSelect: FC<TableSelectProps> = ({
size='small'
value={searchText}
onChange={(event) => setSearchText(event.target.value)}
hideLabel
label={search.label}
placeholder={search.placeholder}
autoFocus
Expand Down