Skip to content

Commit 0e2c39a

Browse files
a-haritistephanie-anderson
authored andcommitted
Fix onboarding options jumping (#10236)
* fix: don't add padding to onboarding options when they're sticking * delete console.log * fix typo * remove rounded corners from OnboardingOptionButtons --------- Co-authored-by: Stephanie Anderson <[email protected]>
1 parent 6dcacc2 commit 0e2c39a

File tree

1 file changed

+3
-30
lines changed

1 file changed

+3
-30
lines changed

src/components/onboarding/index.tsx

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import {ReactNode, useEffect, useReducer, useRef, useState} from 'react';
3+
import {ReactNode, useEffect, useReducer, useState} from 'react';
44
import {QuestionMarkCircledIcon} from '@radix-ui/react-icons';
55
import * as Tooltip from '@radix-ui/react-tooltip';
66
import {Button, Checkbox, Theme} from '@radix-ui/themes';
@@ -176,8 +176,6 @@ export function OnboardingOptionButtons({
176176
`[data-onboarding-option="${option.id}"]`
177177
);
178178
targetElements.forEach(el => {
179-
console.log('el', el.dataset);
180-
181179
const hiddenForThisOption = el.dataset.hideForThisOption === 'true';
182180
if (hiddenForThisOption) {
183181
el.classList.toggle('hidden', option.checked);
@@ -211,35 +209,10 @@ export function OnboardingOptionButtons({
211209
});
212210
}
213211
});
214-
}, [options, touchOptions]);
215-
216-
const buttonsRef = useRef<HTMLDivElement>(null);
217-
const containerTopPx = 80;
218-
const [isSticky, setIsSticky] = useState(false);
219-
220-
useEffect(() => {
221-
const observer = new IntersectionObserver(
222-
function ([buttonsContainer]) {
223-
setIsSticky(!buttonsContainer.isIntersecting);
224-
},
225-
{
226-
// the 1 exptra px is important to trigger the observer
227-
// https://stackoverflow.com/questions/16302483/event-to-detect-when-positionsticky-is-triggered
228-
rootMargin: `-${containerTopPx + 1}px 0px 0px 0px`,
229-
threshold: [1],
230-
}
231-
);
232-
233-
observer.observe(buttonsRef.current!);
234-
}, []);
212+
}, [options, touchedOptions]);
235213

236214
return (
237-
<div
238-
ref={buttonsRef}
239-
className={`flex flex-wrap gap-3 py-2 bg-white/90 sticky top-[80px] z-[1000] rounded shadow-[var(--shadow-6)] transition ${
240-
isSticky ? 'px-2 backdrop-blur' : ''
241-
}`}
242-
>
215+
<div className="flex flex-wrap gap-3 py-2 bg-white/90 sticky top-[80px] z-[1000] shadow-[var(--shadow-6)] transition">
243216
{options.map(option => (
244217
<Button
245218
variant="surface"

0 commit comments

Comments
 (0)