Skip to content

Commit

Permalink
fix(back-top): fix n-back-top has log warnings of console when use sh…
Browse files Browse the repository at this point in the history
…ow prop (#3128)

Co-authored-by: 07akioni <07akioni2@gmail.com>
  • Loading branch information
XieZongChen and 07akioni committed Jun 18, 2022
1 parent 819fabc commit 08ddb72
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixes

- Fix `n-input-group-label`'s content is abnormal in `n-drawer-content`, closes [#3115](https://github.com/TuSimple/naive-ui/issues/3115).
- Fix `n-back-top` has log warnings of console when use `show` prop, closes [#3122](https://github.com/TuSimple/naive-ui/issues/3122).
- `volar.d.ts` remove `[key: string]: any` to solve the code prompt problem in `vscode`.

### Feats
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixes

- 修复 `n-input-group-label` 的内容在 `n-drawer-content` 嵌套中异常, 关闭 [#3115](https://github.com/TuSimple/naive-ui/issues/3115)
- 修复 `n-back-top` 在使用 `show` 时控制台报警告, 关闭 [#3122](https://github.com/TuSimple/naive-ui/issues/3122)
- `volar.d.ts` 去除 `[key: string]: any` ,解决 `vscode` 中代码提示问题

### Feats
Expand Down
10 changes: 6 additions & 4 deletions src/back-top/src/BackTop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ export default defineComponent({
const { mergedClsPrefixRef, inlineThemeDisabled } = useConfig(props)

const scrollTopRef = ref<number | null>(null)
const uncontrolledShowRef = computed(() => {
if (scrollTopRef.value === null) return false
return scrollTopRef.value >= props.visibilityHeight
const uncontrolledShowRef = ref(false)
watchEffect(() => {
if (scrollTopRef.value === null) uncontrolledShowRef.value = false
uncontrolledShowRef.value =
(scrollTopRef.value as number) >= props.visibilityHeight
})
const DomInfoReadyRef = ref(false)
watch(uncontrolledShowRef, (value) => {
if (DomInfoReadyRef.value) {
props['onUpdate:show'](value)
props['onUpdate:show']?.(value)
}
})
const controlledShowRef = toRef(props, 'show')
Expand Down

0 comments on commit 08ddb72

Please sign in to comment.