Skip to content

Commit

Permalink
fix(comp:text): text component should inherit attrs (#1731)
Browse files Browse the repository at this point in the history
  • Loading branch information
sallerli1 committed Nov 3, 2023
1 parent ed78fe3 commit 75b49bf
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
14 changes: 14 additions & 0 deletions packages/components/text/demo/Maxheight.md
@@ -0,0 +1,14 @@
---
order: 20
title:
zh: 最大高度
en: Max height
---

## zh

可以通过样式覆盖修改最大高度,实现内容纵向滚动

## en

Overwrite style of text component to make text content vertially scrollalbe with max height.
27 changes: 27 additions & 0 deletions packages/components/text/demo/Maxheight.vue
@@ -0,0 +1,27 @@
<script lang="ts" setup>
const text = Array.from(new Array(80))
.map(() => '@idux是一套企业级中后台UI组件库, 致力于提供高效愉悦的开发体验。')
.join()
</script>

<template>
<div class="demo-text-max-height">
<IxText :tooltip="false" :ellipsis="{ rows: 4, expandable: true }">
{{ text }}
<template #expandIcon="{ expanded }">
{{ expanded ? '收起' : '展开' }}
</template>
</IxText>
</div>
</template>

<style lang="less">
.demo-text-max-height {
width: 600px;
.ix-text-inner {
display: inline-block;
max-height: 300px;
overflow-y: auto;
}
}
</style>
4 changes: 1 addition & 3 deletions packages/components/text/src/Text.tsx
Expand Up @@ -34,9 +34,8 @@ const rowMeasureElementStyle = {

export default defineComponent({
name: 'IxText',
inheritAttrs: false,
props: textProps,
setup(props, { attrs, slots }) {
setup(props, { slots }) {
const common = useGlobalConfig('common')
const config = useGlobalConfig('text')
const mergedPrefixCls = computed(() => `${common.prefixCls}-text`)
Expand Down Expand Up @@ -129,7 +128,6 @@ export default defineComponent({
class={`${prefixCls}-inner`}
title={isNative && isEllipsis.value ? getStringBySlot(titleSlot) : undefined}
onClick={expandable.value && !hasExpandIcon ? toggleExpanded : undefined}
{...attrs}
>
{!isSimple.value && isEllipsis.value && !expanded.value && measureStatus.value === 'none'
? renderClampedContent(contentNodes)
Expand Down

0 comments on commit 75b49bf

Please sign in to comment.