Does not work when rendered inside an iframe
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
- 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
- 391
- Fork
- 245
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
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 ·
-
Độ 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 ·
-
Độ 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 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
react-component/trigger#495 ·
Tất cả issue của react-component/trigger
Issue tương tự
-
Browser Waiting for: Product Owner
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
getsentry/sentry-javascript#24577 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
agilepathway/label-checker#640 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
copse-dev/agent-pane#2953 ·
-
[aw] Upgrade available Đang mởagentic-workflows
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
githubnext/rig#534 ·
-
automation missing-model model-sync provider:pioneer
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
anomalyco/models.dev#7701 ·