Does not work when rendered inside an iframe
Đá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
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- react, typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Bắt đầu bằng cách tìm đoạn mã định vị trigger và popup có kiểm tra HTMLBodyElement và HTMLHtmlElement bằng instanceof. Tái hiện ví dụ iframe bằng TypeScript được cung cấp và kiểm tra cách phép tính vùng hiển thị xử lý các phần tử thuộc một tài liệu khác. Công việc được xem là hoàn tất khi việc căn chỉnh trigger và popup hoạt động chính xác cả bên trong các tài liệu iframe lẫn tài liệu cha.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Minimal reproduction
import { useEffect, useRef, useState } from 'react';
import { createPortal } from 'react-dom';
import RcTooltip from 'rc-tooltip';
import 'rc-tooltip/assets/bootstrap.css';
function IframeContent({ container }: { container: HTMLElement }) {
return createPortal(
<RcTooltip
overlay="Hello from tooltip"
placement="top"
getTooltipContainer={() => container}
>
<button>Hover me</button>
</RcTooltip>,
container,
);
}
export default function App() {
const iframeRef = useRef<HTMLIFrameElement>(null);
const [mountEl, setMountEl] = useState<HTMLElement | null>(null);
useEffect(() => {
const iframe = iframeRef.current;
if (!iframe) return;
const onLoad = () => {
setMountEl(iframe.contentDocument?.body ?? null);
};
iframe.addEventListener('load', onLoad);
if (iframe.contentDocument?.readyState === 'complete') onLoad();
return () => iframe.removeEventListener('load', onLoad);
}, []);
return (
<>
<iframe
ref={iframeRef}
srcDoc="<!DOCTYPE html><html><body></body></html>"
style={{ width: '100%', height: 200, border: '1px solid #ccc' }}
/>
{mountEl && <IframeContent container={mountEl} />}
</>
);
}
Expected behavior
@rc-component/trigger should support trigger and popup elements rendered inside iframe documents.
Popup positioning and visible area calculation should work regardless of whether the DOM elements come from the parent document or an iframe document.
Actual behavior
When rendered inside an iframe, popup alignment/visible area calculation can be incorrect because iframe <body> and <html> elements fail the instanceof HTMLBodyElement / instanceof HTMLHtmlElement checks.
- Ngôn ngữ chính
- TypeScript
- Star
- 392
- Fork
- 250
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
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/trigger
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
react-component/trigger#593 · 1 reaction ·
-
useAlign reuses a stale flip decision after the viewport changes (popup stays flipped until reopen)Có thể đã có người làm @SXongin đã nhận 34 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 30/100
react-component/trigger#651 ·
-
useAlign.js: inline style reset to 0 is silently overridden under prefers-reduced-motion CSS (CSSTransition interpolation)Có thể đã có người làm @baofuen đã nhận 144 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
react-component/trigger#618 · 1 bình luận ·
-
`collectScroller` is not working as expected when the element is in shadow DOMCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
react-component/trigger#555 ·
-
points: ['cc', 'cc'] 无法自适应调整位置Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
react-component/trigger#550 · 1 bình luận ·
Tất cả issue của react-component/trigger
Issue tương tự
-
dependencies effort: small good first issue priority: low
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
TMHSDigital/screencast-mcp#509 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
from-review tech-debt testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
blamechris/chroxy#9520 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:web complexity:S priority:P2 type:chore
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
nahuelcostac/agent-hub#104 ·
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 77/100
snaglet-org/snaglet#78 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent/guide documentation help wanted stage/010-actionable
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
kubestellar/console-marketplace#1101 ·
Maintainer thường phản hồi trong vòng 1 ngày