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

Avatar bug #780

Closed
wants to merge 4 commits into from
Closed

Avatar bug #780

wants to merge 4 commits into from

Conversation

Volankey
Copy link
Collaborator

@Volankey Volankey commented Aug 5, 2021

closes #779

@vercel
Copy link

vercel bot commented Aug 5, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tusimple/naive-ui/FKercUHFqL8bdyUN3bnraGUKn8VL
✅ Preview: https://naive-ui-git-fork-volankey-avatar-bug-tusimple.vercel.app

@codecov
Copy link

codecov bot commented Aug 5, 2021

Codecov Report

Merging #780 (15eaf9d) into main (648392b) will decrease coverage by 0.11%.
The diff coverage is 0.00%.

❗ Current head 15eaf9d differs from pull request most recent head f2469e4. Consider uploading reports for the commit f2469e4 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #780      +/-   ##
==========================================
- Coverage   40.25%   40.13%   -0.12%     
==========================================
  Files         507      507              
  Lines       12393    12395       +2     
  Branches     3479     3480       +1     
==========================================
- Hits         4989     4975      -14     
- Misses       6494     6503       +9     
- Partials      910      917       +7     
Impacted Files Coverage Δ
src/avatar/src/Avatar.tsx 85.71% <0.00%> (-8.04%) ⬇️
src/progress/src/Line.tsx 37.03% <0.00%> (-37.04%) ⬇️
src/_utils/css/format-length.ts 61.11% <0.00%> (-16.67%) ⬇️
src/modal/src/BodyWrapper.tsx 29.03% <0.00%> (-1.13%) ⬇️
src/modal/src/Modal.tsx 29.16% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 648392b...f2469e4. Read the comment docs.

Comment on lines 62 to 66
// FIX: use v-show elWidth is 0, need to recompute elWidth while update
if (elWidth === 0) {
memoedTextHtml = null
return
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里会不会有其他的 elWidth === 0 的时候?想办法写的更安全一点吧

textEl.style.transform = `translateX(-50%) translateY(-50%) scale(${ratio})`
// FIX: use v-show elWidth is 0, need to recompute elWidth while update
// reference: https://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom
void nextTick(() => {
Copy link
Collaborator Author

@Volankey Volankey Aug 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用nextTick是针对这种情况

<div v-show="show">
  <n-avatar>Name</n-avatar>
</div>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样似乎并不能解决

<div v-show="show">
  <n-avatar>Name</n-avatar>
</div>

造成的样式问题

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我这边试了没啥问题的

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我这样测试的,样式不能正常加载

<template>
  <div>
    <button @click='toggle'>toggle</button>
    <div v-show="isShow">
      <n-avatar>Name</n-avatar>
    </div>
  </div>
</template>

<script>
import { defineComponent, ref } from 'vue'

export default defineComponent({
  setup () {
    const isShow = ref(false)
    const toggle = () => {
      isShow.value = !isShow.value
    }
    return {
      value: ref('Oasis111'),
      toggle,
      isShow
    }
  }
})
</script>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

您再看看呢

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你是通过codesandbox测试的吗?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是在本地 写了个demo测试的

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确实无法处理这种静态的节点,强行做的话会比较麻烦 @07akioni

<div v-show="show">
  <n-avatar>Name</n-avatar>
</div>

@07akioni
Copy link
Collaborator

07akioni commented Aug 7, 2021

我来解决吧

@07akioni
Copy link
Collaborator

07akioni commented Aug 7, 2021

修了,用 ResizeObserver

@07akioni 07akioni closed this Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v-show造成Avatar组件样式渲染出现bug(v-show caused a bug in Avatar component style rendering)
4 participants