Skip to content

Commit

Permalink
fix(Link): disabled priority
Browse files Browse the repository at this point in the history
  • Loading branch information
liweijie0812 committed Jul 16, 2024
1 parent fce4f2c commit c20293a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/link/link.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name | type | default | description | required
-- | -- | -- | -- | --
content | String / Slot / Function | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
default | String / Slot / Function | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
disabled | Boolean | - | make link to be disabled | N
disabled | Boolean | undefined | make link to be disabled | N
hover | Boolean | - | \- | N
href | String | - | \- | N
prefixIcon | Slot / Function | - | Typescript:`TNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
Expand Down
2 changes: 1 addition & 1 deletion src/link/link.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
-- | -- | -- | -- | --
content | String / Slot / Function | - | 链接内容。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
default | String / Slot / Function | - | 链接内容,同 content。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
disabled | Boolean | - | 禁用链接 | N
disabled | Boolean | undefined | 禁用链接。优先级:Link.disabled > Form.disabled | N
hover | Boolean | - | 是否开启点击反馈 | N
href | String | - | 跳转链接 | N
prefixIcon | Slot / Function | - | 前置图标。TS 类型:`TNode`[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
Expand Down
13 changes: 7 additions & 6 deletions src/link/link.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { defineComponent, computed } from 'vue';
import config from '../config';
import LinkProps from './props';
import props from './props';
import { useContent, useTNodeJSX } from '../hooks/tnode';
import { usePrefixClass } from '../hooks/useClass';
import { useFormDisabled } from '../form/hooks';

const { prefix } = config;
const name = `${prefix}-link`;
export default defineComponent({
name,
props: LinkProps,
name: `${prefix}-link`,
props,
setup(props) {
const linkClass = usePrefixClass('link');
const renderTNodeJSX = useTNodeJSX();
const renderTNodeContent = useContent();
const isDisabled = useFormDisabled();

const linkClasses = computed(() => [
linkClass.value,
Expand Down Expand Up @@ -49,9 +50,9 @@ export default defineComponent({
return (
<a
class={linkClasses.value}
aria-disabled={props.disabled}
aria-disabled={isDisabled.value}
target={props.target}
href={props.disabled || !props.href ? undefined : props.href}
href={isDisabled.value || !props.href ? undefined : props.href}
onClick={handleClick}
>
{renderPrefixIcon()}
Expand Down
7 changes: 5 additions & 2 deletions src/link/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ export default {
default: {
type: [String, Function] as PropType<TdLinkProps['default']>,
},
/** 禁用链接 */
disabled: Boolean,
/** 禁用链接。优先级:Link.disabled > Form.disabled */
disabled: {
type: Boolean,
default: undefined,
},
/** 是否开启点击反馈 */
hover: Boolean,
/** 跳转链接 */
Expand Down
2 changes: 1 addition & 1 deletion src/link/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface TdLinkProps {
*/
default?: string | TNode;
/**
* 禁用链接
* 禁用链接。优先级:Link.disabled > Form.disabled
*/
disabled?: boolean;
/**
Expand Down

0 comments on commit c20293a

Please sign in to comment.