Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dbadura committed Jul 19, 2024
1 parent a2c7750 commit 820358b
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
import { Button, Popover, Text } from '@ui5/webcomponents-react';
import { createPortal } from 'react-dom';
import { useRef, useState } from 'react';
import { CSSProperties, ReactNode, useRef, useState } from 'react';
import { uniqueId } from 'lodash';

type HintButtonProps = {
setShowTitleDescription: any;
showTitleDescription: boolean;
description: string | ReactNode;
style?: CSSProperties;
};

export function HintButton({
setShowTitleDescription,
showTitleDescription,
description,
style,
dataTestID = null,
}) {
const [uniqueID] = useState(uniqueId('id-'));
}: HintButtonProps) {
const [uniqueID] = useState(uniqueId('id-')); //todo: migrate to useID from react after upgrade to version 18+
const descBtnRef = useRef(null);

return (
<>
<Button
id={`descriptionOpener-${uniqueID}`} //migrate to useID from react after upgrade to version 18+
id={`descriptionOpener-${uniqueID}`}
ref={descBtnRef}
icon="hint"
design="Transparent"
Expand All @@ -24,13 +31,13 @@ export function HintButton({
e.stopPropagation();
setShowTitleDescription(true);
}}
data-testid={dataTestID}
/>
{createPortal(
<Popover
opener={`descriptionOpener-${uniqueID}`}
//Point initial focus to other component removes the focus from the link in description
onAfterOpen={() => {
// @ts-ignore
descBtnRef.current.focus();
}}
open={showTitleDescription}
Expand Down

0 comments on commit 820358b

Please sign in to comment.