mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 06:56:38 +00:00
dd5ccade2b
* autoscale and manual radiobuutton fixes * alt text attribute for images * Revert "alt text attribute for images" This reverts commit5a660551c6
. * alt text for decorative images * sev2 accessibilitydefects in data explorer * Revert "sev2 accessibilitydefects in data explorer" This reverts commitb84d5b572c
. * Sev2 accessibilitydefects * Revert "Sev2 accessibilitydefects" This reverts commita4e60f106c
. * accessibilitydefects-data explorer * Accessibility sev-2 defects-2 * corrections for 2278347,2278096 and fix for 2264174 * corrections for 2278347,2278096 and fix for 2264174 * fix for defect 2276938 * wrong aria attibute used * refresh, expand, collapse tree does not have proper label for screenreader * Update treeComponent.less * Update TableEntity.tsx * Update MiddlePaneComponent.tsx
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import React, { FunctionComponent, MutableRefObject, useEffect, useRef } from "react";
|
|
import arrowLeftImg from "../../images/imgarrowlefticon.svg";
|
|
import { getApiShortDisplayName } from "../Utils/APITypeUtils";
|
|
import { NormalizedEventKey } from "./Constants";
|
|
|
|
export interface CollapsedResourceTreeProps {
|
|
toggleLeftPaneExpanded: () => void;
|
|
isLeftPaneExpanded: boolean;
|
|
}
|
|
|
|
export const CollapsedResourceTree: FunctionComponent<CollapsedResourceTreeProps> = ({
|
|
toggleLeftPaneExpanded,
|
|
isLeftPaneExpanded,
|
|
}: CollapsedResourceTreeProps): JSX.Element => {
|
|
const focusButton = useRef<HTMLLIElement>() as MutableRefObject<HTMLLIElement>;
|
|
|
|
useEffect(() => {
|
|
if (focusButton.current) {
|
|
focusButton.current.focus();
|
|
}
|
|
});
|
|
|
|
const onKeyPressToggleLeftPaneExpanded = (event: React.KeyboardEvent) => {
|
|
if (event.key === NormalizedEventKey.Space || event.key === NormalizedEventKey.Enter) {
|
|
toggleLeftPaneExpanded();
|
|
event.stopPropagation();
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div id="mini" className={!isLeftPaneExpanded ? "mini toggle-mini" : "hiddenMain"}>
|
|
<div className="main-nav nav">
|
|
<ul className="nav">
|
|
<li
|
|
className="resourceTreeCollapse"
|
|
id="collapseToggleLeftPaneButton"
|
|
role="button"
|
|
tabIndex={0}
|
|
aria-label={getApiShortDisplayName() + `Expand tree`}
|
|
onClick={toggleLeftPaneExpanded}
|
|
onKeyPress={onKeyPressToggleLeftPaneExpanded}
|
|
ref={focusButton}
|
|
>
|
|
<span className="leftarrowCollapsed">
|
|
<img className="arrowCollapsed" src={arrowLeftImg} alt="Expand" />
|
|
</span>
|
|
<span className="collectionCollapsed">
|
|
<span>{getApiShortDisplayName()}</span>
|
|
</span>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|