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

fix: change span to div in Trigger, the problem with semantic error #754

Merged
merged 2 commits into from
Jun 21, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/Popover/Popover.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ $block: '.#{variables.$ns}popover';
cursor: pointer;
}

&__handler {
display: inline;
}

$class: &;

&__tooltip {
Expand Down
1 change: 1 addition & 0 deletions src/components/Popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export const Popover = React.forwardRef<PopoverInstanceProps, PopoverProps & QAP
closeTooltip={closeTooltip}
openTooltip={openTooltip}
open={isOpen}
className={cnPopover('handler')}
disabled={disabled}
onClick={onClick}
closedManually={closedManually}
Expand Down
17 changes: 13 additions & 4 deletions src/components/Popover/components/Trigger/Trigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ export type TriggerProps = {
* Tooltip's opened state
*/
open: boolean;
/**
* Css class for the control
*/
className?: string;
/**
* click handler
*/
onClick?: (event: React.MouseEvent<HTMLSpanElement>) => boolean | Promise<boolean>;
onClick?: (event: React.MouseEvent<HTMLDivElement>) => boolean | Promise<boolean>;
/**
* Disables open state changes
*/
Expand All @@ -34,13 +38,14 @@ export type TriggerProps = {
export const Trigger = ({
open,
disabled,
className,
openTooltip,
closeTooltip,
closedManually,
onClick,
children,
}: TriggerProps) => {
const handleClick = async (event: React.MouseEvent<HTMLSpanElement>) => {
const handleClick = async (event: React.MouseEvent<HTMLDivElement>) => {
if (disabled) {
return;
}
Expand All @@ -66,6 +71,10 @@ export const Trigger = ({
toggleTooltip();
};

// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
return <span onClick={handleClick}>{children}</span>;
return (
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<div className={className} onClick={handleClick}>
{children}
</div>
);
};