Select: custom `popupRender` content stays stale after the dropdown closes, with no way to opt out
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 58/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Start in the trigger package: read src/Popup/PopupContent.tsx (the React.memo comparing next.cache) and the cache: !open && !fresh / CSSMotion removeOnLeave: false setup in src/Popup/index.tsx, then follow how BaseSelect builds the fixed prop list for SelectTrigger and dumps everything else into restProps for SelectInput. Deciding which prop name to expose (destroyOnHidden vs plumbing fresh/autoDestroy) is an open API question the thread has not settled. Done means the prop reaches the trigger from Select and the hidden .ant-select-dropdown re-renders, verified by a test that reads .preview after Esc.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Environment
@rc-component/select1.12.0 (same behavior throughantd6.7.2), React 19
What happens
When popupRender renders UI that is derived from component state, that UI is frozen once the dropdown closes. Example: a two-column dropdown where the left column is the option list and the right column is a preview panel that follows the currently hovered option.
- open the dropdown, hover option B → preview panel shows B
- close with
Esc(no selection) → the select value is unchanged, state is reset - the hidden
.ant-select-dropdownstill shows B's preview; later state changes do not reach it either - reopening recomputes correctly, so this is invisible in the UI — but DOM inspection, e2e assertions and a11y/audit tooling read stale content
Where it comes from (traced, not guessed)
@rc-component/triggersrc/Popup/PopupContent.tsx:React.memo(({ children }) => children, (_, next) => next.cache), withcache: !open && !freshset insrc/Popup/index.tsx. Closed popup children are intentionally not re-rendered.src/Popup/index.tsxrendersCSSMotionwithremoveOnLeave: false, so the popup DOM is kept (class-hidden) rather than unmounted. Also intentional for perf.
So the trigger layer already has the knobs needed (fresh, autoDestroy), but BaseSelect passes SelectTrigger a fixed prop list (visible, popupElement, popupRender, popupAlign, ...). Everything else lands in restProps and goes to SelectInput, so fresh / autoDestroy set on Select never reach the trigger. Neither prop is exposed by Select either.
Minimal repro
const [hover, setHover] = useState('a');
<Select
open
options={[{ value: 'a', label: 'A' }, { value: 'b', label: 'B' }]}
optionRender={(opt) => (
<div onMouseEnter={() => setHover(String(opt.value))}>{opt.label}</div>
)}
popupRender={(menu) => (
<div style={{ display: 'flex' }}>
<div>{menu}</div>
<div className="preview">{hover === 'b' ? 'Preview B' : 'Preview A'}</div>
</div>
)}
/>
Hover "B", press Esc, then read document.querySelector('.preview').textContent → still Preview B.
Expected
Either the hidden popup content stays in sync with the current state, or there is an explicit switch for it.
Proposal
- expose
destroyOnHidden(matching the antd v6 naming used by Modal/Tabs/Drawer) onSelect, or - at minimum pass
fresh/autoDestroythrough toSelectTriggerso callers can opt in.
Not asking to change the default (caching and keeping the DOM is clearly a perf choice) — only to make it controllable.
- Ngôn ngữ chính
- TypeScript
- Star
- 940
- Fork
- 485
- Merge trung bình
- 8 giờ 4 phút
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của react-component/select
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
react-component/select#1216 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
react-component/select#1159 ·
-
a11y 问题Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
react-component/select#1087 · 1 reaction ·
-
showSearch 默认值是 false 把Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
react-component/select#1086 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 30/100
react-component/select#1082 · 1 bình luận ·
Tất cả issue của react-component/select
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
Techiebutler/freeframe#687 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement from-app needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
nightly-labs/openbot#23050 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OHDSI/Data2Evidence#3846 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
frontend: EditorDialog: Save & Apply on an empty or comment-only document reports success and applies nothingCó thể đã có người làm @shubhamrai9122-creator đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
kubernetes-sigs/headlamp#9086 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
openai/openai-node#3232 ·
Maintainer thường phản hồi trong vòng 1 ngày