= props => {
)}
style={{
...(posInfo || CENTER_PLACEHOLDER),
- position: 'fixed',
+ position: inlineMode ? 'absolute' : 'fixed',
pointerEvents: 'none',
...style,
}}
diff --git a/src/hooks/useTarget.ts b/src/hooks/useTarget.ts
index 3d262c7..73976fa 100644
--- a/src/hooks/useTarget.ts
+++ b/src/hooks/useTarget.ts
@@ -25,6 +25,8 @@ export default function useTarget(
open: boolean,
gap?: Gap,
scrollIntoViewOptions?: boolean | ScrollIntoViewOptions,
+ inlineMode?: boolean,
+ placeholderRef?: React.RefObject
,
): [PosInfo, HTMLElement] {
// ========================= Target =========================
// We trade `undefined` as not get target by function yet.
@@ -53,6 +55,17 @@ export default function useTarget(
targetElement.getBoundingClientRect();
const nextPosInfo: PosInfo = { left, top, width, height, radius: 0 };
+ // If `inlineMode` we need cut off parent offset
+ if (inlineMode) {
+ const parentRect =
+ placeholderRef.current?.parentElement?.getBoundingClientRect();
+
+ if (parentRect) {
+ nextPosInfo.left -= parentRect.left;
+ nextPosInfo.top -= parentRect.top;
+ }
+ }
+
setPosInfo(origin => {
if (JSON.stringify(origin) !== JSON.stringify(nextPosInfo)) {
return nextPosInfo;
diff --git a/src/interface.ts b/src/interface.ts
index ce7754b..3cfa6b3 100644
--- a/src/interface.ts
+++ b/src/interface.ts
@@ -53,6 +53,7 @@ export interface TourProps extends Pick {
style?: React.CSSProperties;
steps?: TourStepInfo[];
open?: boolean;
+ defaultOpen?: boolean;
defaultCurrent?: number;
current?: number;
onChange?: (current: number) => void;
@@ -76,7 +77,7 @@ export interface TourProps extends Pick {
animated?: boolean | { placeholder: boolean };
scrollIntoViewOptions?: boolean | ScrollIntoViewOptions;
zIndex?: number;
- getPopupContainer?: TriggerProps['getPopupContainer'];
+ getPopupContainer?: TriggerProps['getPopupContainer'] | false;
builtinPlacements?:
| TriggerProps['builtinPlacements']
| ((config?: {
diff --git a/tests/__snapshots__/index.test.tsx.snap b/tests/__snapshots__/index.test.tsx.snap
index aa16fd2..823f744 100644
--- a/tests/__snapshots__/index.test.tsx.snap
+++ b/tests/__snapshots__/index.test.tsx.snap
@@ -51,7 +51,7 @@ exports[`Tour animated placeholder true 1`] = `
/>
@@ -204,7 +204,7 @@ exports[`Tour animated true 1`] = `
/>
@@ -385,7 +385,7 @@ exports[`Tour renderPanel basic 1`] = `
/>
@@ -496,7 +496,7 @@ exports[`Tour rootClassName 1`] = `
/>
@@ -780,7 +780,7 @@ exports[`Tour run in strict mode 2`] = `
/>
@@ -1194,7 +1194,7 @@ exports[`Tour should update position when window resize 1`] = `
/>
@@ -1331,7 +1331,7 @@ exports[`Tour showArrow should show tooltip arrow default 1`] = `
/>
@@ -1480,7 +1480,7 @@ exports[`Tour single 1`] = `
/>
@@ -1635,7 +1635,7 @@ exports[`Tour use custom builtinPlacements 1`] = `
/>
@@ -1790,7 +1790,7 @@ exports[`Tour use custom builtinPlacements 2`] = `
/>
@@ -1956,7 +1956,7 @@ exports[`Tour use custom builtinPlacements 3`] = `
/>
diff --git a/tests/index.test.tsx b/tests/index.test.tsx
index 1b18036..a213561 100644
--- a/tests/index.test.tsx
+++ b/tests/index.test.tsx
@@ -1197,4 +1197,32 @@ describe('Tour', () => {
expect(footerElement.style.borderTop).toBe('1px solid black');
expect(descriptionElement.style.fontStyle).toBe('italic');
});
+
+ it('inline', async () => {
+ const Demo = () => {
+ const btnRef = useRef(null);
+ return (
+
+
+ ,
+ target: () => btnRef.current,
+ },
+ ]}
+ />
+
+ );
+ };
+ render();
+ const container = document.querySelector('.bamboo');
+ const children = container.querySelector('.little');
+
+ // Check container has children
+ expect(children).toBeTruthy();
+ });
});