Skip to content

Commit

Permalink
fix(Clickable): more Components in checkClickable (#7390)
Browse files Browse the repository at this point in the history
Добавляем больше компонентов в проверке кликабельности
  • Loading branch information
SevereCloud authored Aug 15, 2024
1 parent d3858fe commit 590f508
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 29 deletions.
4 changes: 2 additions & 2 deletions packages/vkui/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { classNames, hasReactNode, noop } from '@vkontakte/vkjs';
import { classNames, hasReactNode } from '@vkontakte/vkjs';
import { useAdaptivity } from '../../hooks/useAdaptivity';
import { usePlatform } from '../../hooks/usePlatform';
import { HasAlign } from '../../types';
Expand Down Expand Up @@ -70,7 +70,7 @@ export const Button = ({
after,
getRootRef,
loading,
onClick = noop,
onClick,
className,
disableSpinnerAnimation,
rounded,
Expand Down
6 changes: 3 additions & 3 deletions packages/vkui/src/components/Cell/Cell.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { classNames, noop } from '@vkontakte/vkjs';
import { classNames } from '@vkontakte/vkjs';
import type { SwappedItemRange } from '../../hooks/useDraggableWithDomApi';
import { useExternRef } from '../../hooks/useExternRef';
import { usePlatform } from '../../hooks/usePlatform';
Expand Down Expand Up @@ -52,7 +52,7 @@ export const Cell: React.FC<CellProps> & {
Checkbox: typeof CellCheckbox;
} = ({
mode,
onRemove = noop,
onRemove,
removePlaceholder = 'Удалить',
onDragFinish,
before,
Expand Down Expand Up @@ -167,7 +167,7 @@ export const Cell: React.FC<CellProps> & {
style={style}
getRootRef={rootElRef}
removePlaceholder={removePlaceholder}
onRemove={(e) => onRemove(e, rootElRef.current)}
onRemove={(e) => onRemove?.(e, rootElRef.current)}
toggleButtonTestId={toggleButtonTestId}
removeButtonTestId={removeButtonTestId}
>
Expand Down
6 changes: 3 additions & 3 deletions packages/vkui/src/components/ChipsInputBase/Chip/Chip.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { Icon16Cancel } from '@vkontakte/icons';
import { classNames, hasReactNode, noop } from '@vkontakte/vkjs';
import { classNames, hasReactNode } from '@vkontakte/vkjs';
import { useAdaptivity } from '../../../hooks/useAdaptivity';
import { useFocusVisible } from '../../../hooks/useFocusVisible';
import { useFocusVisibleClassName } from '../../../hooks/useFocusVisibleClassName';
Expand All @@ -22,7 +22,7 @@ export const Chip = ({
Component = 'span',
value = '',
removable = true,
onRemove = noop,
onRemove,
removeLabel = 'Удалить',
before,
after,
Expand Down Expand Up @@ -54,7 +54,7 @@ export const Chip = ({

const onRemoveWrapper = React.useCallback(
(event: React.MouseEvent) => {
onRemove(event, value);
onRemove?.(event, value);
},
[onRemove, value],
);
Expand Down
5 changes: 4 additions & 1 deletion packages/vkui/src/components/Clickable/Clickable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ export function checkClickable<T>(props: ClickableProps<T>): boolean {
(props.href !== undefined ||
props.onClick !== undefined ||
props.onClickCapture !== undefined ||
props.Component === 'label') &&
props.Component === 'a' ||
props.Component === 'button' ||
props.Component === 'label' ||
props.Component === 'input') &&
!props.disabled
);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/vkui/src/components/FormItem/FormItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { classNames, hasReactNode, noop } from '@vkontakte/vkjs';
import { classNames, hasReactNode } from '@vkontakte/vkjs';
import { useAdaptivity } from '../../hooks/useAdaptivity';
import { useExternRef } from '../../hooks/useExternRef';
import { useObjectMemo } from '../../hooks/useObjectMemo';
Expand Down Expand Up @@ -89,7 +89,7 @@ export const FormItem: React.FC<FormItemProps> & {
bottom,
status = 'default',
removable,
onRemove = noop,
onRemove,
removePlaceholder = 'Удалить',
getRootRef,
htmlFor,
Expand Down Expand Up @@ -154,7 +154,7 @@ export const FormItem: React.FC<FormItemProps> & {
align="start"
onRemove={(e) => {
if (rootEl?.current) {
onRemove(e, rootEl.current);
onRemove?.(e, rootEl.current);
}
}}
removePlaceholder={removePlaceholder}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { classNames, noop } from '@vkontakte/vkjs';
import { classNames } from '@vkontakte/vkjs';
import { useAdaptivity } from '../../hooks/useAdaptivity';
import { useExternRef } from '../../hooks/useExternRef';
import { HTMLAttributesWithRootRef } from '../../types';
Expand Down Expand Up @@ -44,7 +44,7 @@ export const FormLayoutGroup = ({
removable,
segmented,
removePlaceholder = 'Удалить',
onRemove = noop,
onRemove,
getRootRef,
...restProps
}: FormLayoutGroupProps): React.ReactNode => {
Expand Down Expand Up @@ -89,7 +89,7 @@ export const FormLayoutGroup = ({
removePlaceholder={removePlaceholder}
onRemove={(e) => {
if (rootEl?.current) {
onRemove(e, rootEl.current);
onRemove?.(e, rootEl.current);
}
}}
indent={removable === 'indent'}
Expand Down
4 changes: 1 addition & 3 deletions packages/vkui/src/components/Link/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { classNames, noop } from '@vkontakte/vkjs';
import { classNames } from '@vkontakte/vkjs';
import { Tappable, TappableProps } from '../Tappable/Tappable';
import styles from './Link.module.css';

Expand All @@ -16,13 +16,11 @@ export const Link = ({
hasVisited,
children,
className,
onClick = noop,
...restProps
}: LinkProps): React.ReactNode => {
return (
<Tappable
Component={restProps.href ? 'a' : 'button'}
onClick={onClick}
{...restProps}
className={classNames(styles['Link'], hasVisited && styles['Link--has-visited'], className)}
hasHover={false}
Expand Down
6 changes: 3 additions & 3 deletions packages/vkui/src/components/Removable/Removable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { Icon24Cancel } from '@vkontakte/icons';
import { classNames, noop } from '@vkontakte/vkjs';
import { classNames } from '@vkontakte/vkjs';
import { useGlobalEventListener } from '../../hooks/useGlobalEventListener';
import { usePlatform } from '../../hooks/usePlatform';
import { getTextFromChildren } from '../../lib/children';
Expand Down Expand Up @@ -155,7 +155,7 @@ interface RemovableOwnProps
*/
export const Removable = ({
children,
onRemove = noop,
onRemove,
removePlaceholder = 'Удалить',
align = 'center',
indent = false,
Expand All @@ -167,7 +167,7 @@ export const Removable = ({

const onRemoveClick = (e: React.MouseEvent) => {
e.preventDefault();
onRemove(e);
onRemove?.(e);
};

const removePlaceholderString: string = getTextFromChildren(removePlaceholder);
Expand Down
4 changes: 2 additions & 2 deletions packages/vkui/src/components/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const Search = ({
after = 'Отмена',
getRef,
icon: iconProp,
onIconClick = noop,
onIconClick,
style,
autoComplete = 'off',
onChange,
Expand Down Expand Up @@ -115,7 +115,7 @@ export const Search = ({
}, [inputRef]);

const onIconClickStart: React.PointerEventHandler<HTMLElement> = React.useCallback(
(e) => onIconClick(e),
(e) => onIconClick?.(e),
[onIconClick],
);

Expand Down
6 changes: 3 additions & 3 deletions packages/vkui/src/components/Snackbar/Snackbar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { classNames, noop } from '@vkontakte/vkjs';
import { classNames } from '@vkontakte/vkjs';
import { useExternRef } from '../../hooks/useExternRef';
import { useFocusWithin } from '../../hooks/useFocusWithin';
import { useGlobalEscKeyDown } from '../../hooks/useGlobalEscKeyDown';
Expand Down Expand Up @@ -89,7 +89,7 @@ export const Snackbar: React.FC<SnackbarProps> & { Basic: typeof Basic } = ({
before,
after,
duration = 4000,
onActionClick = noop,
onActionClick,
onClose,
mode = 'default',
subtitle,
Expand Down Expand Up @@ -157,7 +157,7 @@ export const Snackbar: React.FC<SnackbarProps> & { Basic: typeof Basic } = ({
const handleActionClick = (event: React.MouseEvent) => {
close();
if (action) {
onActionClick(event);
onActionClick?.(event);
}
};

Expand Down
4 changes: 1 addition & 3 deletions packages/vkui/src/components/ToolButton/ToolButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { classNames, hasReactNode, noop } from '@vkontakte/vkjs';
import { classNames, hasReactNode } from '@vkontakte/vkjs';
import { useAdaptivity } from '../../hooks/useAdaptivity';
import {
AdaptiveIconRenderer,
Expand Down Expand Up @@ -52,7 +52,6 @@ export const ToolButton = ({
mode = 'primary',
appearance = 'accent',
direction = 'row',
onClick = noop,
className,
children,
IconCompact,
Expand All @@ -69,7 +68,6 @@ export const ToolButton = ({
activeMode={styles['ToolButton--active']}
Component={restProps.href ? 'a' : 'button'}
focusVisibleMode="outside"
onClick={onClick}
className={classNames(
className,
styles['ToolButton'],
Expand Down

0 comments on commit 590f508

Please sign in to comment.