From 2ad121a0920e75f38245ddbb667e45ca1c4e94cf Mon Sep 17 00:00:00 2001 From: Aswath K Date: Thu, 24 Feb 2022 12:34:31 +0530 Subject: [PATCH] feat: Keyboard accessible property pane header (#11339) --- app/client/src/components/ads/Button.tsx | 3 +- app/client/src/components/ads/Dropdown.tsx | 17 ++++----- .../Editor/PropertyPane/ConnectDataCTA.tsx | 11 ++++-- .../PropertyPane/PropertyPaneConnections.tsx | 35 ++++++++++++++++--- .../Editor/PropertyPane/PropertyPaneView.tsx | 4 +-- 5 files changed, 52 insertions(+), 18 deletions(-) diff --git a/app/client/src/components/ads/Button.tsx b/app/client/src/components/ads/Button.tsx index 815c2ec0f9..d0b35668b2 100644 --- a/app/client/src/components/ads/Button.tsx +++ b/app/client/src/components/ads/Button.tsx @@ -378,7 +378,8 @@ const ButtonStyles = css` fill: ${(props) => btnColorStyles(props, "main").txtColor}; } } - &:hover { + &:hover, + &:focus { text-decoration: none; background-color: ${(props) => btnColorStyles(props, "hover").bgColor}; color: ${(props) => btnColorStyles(props, "hover").txtColor}; diff --git a/app/client/src/components/ads/Dropdown.tsx b/app/client/src/components/ads/Dropdown.tsx index 37bec2ec20..e42218c131 100644 --- a/app/client/src/components/ads/Dropdown.tsx +++ b/app/client/src/components/ads/Dropdown.tsx @@ -687,14 +687,6 @@ export function RenderDropdownOptions(props: DropdownOptionsProps) { maxHeight={props.dropdownMaxHeight || "auto"} > {options.map((option: DropdownOption, index: number) => { - if (renderOption) { - return renderOption({ - option, - index, - optionClickHandler, - optionWidth, - }); - } let isSelected = false; if ( props.isMultiSelect && @@ -708,6 +700,15 @@ export function RenderDropdownOptions(props: DropdownOptionsProps) { isSelected = (props.selected as DropdownOption).value === option.value; } + if (renderOption) { + return renderOption({ + option, + index, + optionClickHandler, + optionWidth, + isSelectedNode: isSelected, + }); + } return !option.isSectionHeader ? ( props.theme.spaces[2]}px 0px; - a:first-child { + button:first-child { margin-top: ${(props) => props.theme.spaces[2]}px; + width: 100%; } - a:nth-child(2) { + button:nth-child(2) { border: none; background-color: transparent; text-transform: none; @@ -43,7 +44,7 @@ const StyledDiv = styled.div` ${(props) => getTypographyByKey(props, "p3")} margin-top: ${(props) => props.theme.spaces[2]}px; - :hover { + :hover, :focus { text-decoration: underline; } } @@ -95,11 +96,15 @@ function ConnectDataCTA(props: ConnectDataCTAProps) { category={Category.primary} onClick={onClick} size={Size.large} + tabIndex={0} + tag="button" text="CONNECT DATA" />