Skip to content

Commit

Permalink
fix: image size
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed Sep 24, 2024
1 parent 5e86e79 commit 5742628
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"**/__snapshots__/**": true,
"CHANGELOG-CODE.md": true,
"patches/**": true
}
},
"image-manager.viewer.imageWidth": 99
}
13 changes: 12 additions & 1 deletion src/webview/image-manager/components/image-collapse/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { memo, type ReactNode, useEffect, useMemo, useRef, useState } from 'react'
import { memo, type ReactNode, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
import { Element, scroller } from 'react-scroll'
import { styleObjectToString } from '@minko-fe/style-object-to-string'
import { useMemoizedFn } from 'ahooks'
Expand Down Expand Up @@ -132,6 +132,7 @@ function ImageCollapse(props: ImageCollapseProps) {

const [activeKeys, setActiveKeys] = useControlledState<string[]>({
defaultValue: (collapseProps.defaultActiveKey as string[]) || [],
value: collapseProps.activeKey as string[] | undefined,
// 当 activeKeys 变化时,更新 activeCollapseIdSet
onChange: (keys) => {
setActiveCollapseIdSet(
Expand All @@ -146,6 +147,16 @@ function ImageCollapse(props: ImageCollapseProps) {
},
})

useLayoutEffect(() => {
if (collapseProps.defaultActiveKey) {
setActiveCollapseIdSet(
produce((draft) => {
draft.add(id)
}),
)
}
}, [])

useEffect(() => {
if (activeCollapseIdSet.has(id) && !activeKeys.includes(id)) {
setActiveKeys([id])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function LazyImageMemo(
...antdImageProps,
src: image.vscodePath,
}),
[image.vscodePath],
[image.vscodePath, antdImageProps],
)

return (
Expand Down

0 comments on commit 5742628

Please sign in to comment.