DEV Community

Deepak Jha
Deepak Jha

Posted on

Vertical Scroll Bar Appears on Mabel Info Popup in Vite Memory Card Project

I'm working on a memory card project using Vite, and I've run into an issue with a popup component. When the Mabel info pops up after clicking the question mark, a vertical scroll bar briefly appears, even though only about 0.1% scrolling is enabled. This disrupts the user interface, making it visually unappealing.

For code reference, here’s the link to my project repo: Deepak-Jha-2025/memory-card

Here are the relevant components:

Footer.jsx:

import MabelInfo from "./MabelInfo";
import Volume from "../assets/img/volume.svg?react";
import VolumeOff from "../assets/img/volume_off.svg?react";
import Music from "../assets/img/music_sign.svg?react";
import MusicOff from "../assets/img/music_off.svg?react";
import QuestionMark from "../assets/img/question_mark.svg?react";
import Cross from "../assets/img/cross.svg?react";
import { motion, AnimatePresence } from "framer-motion";
import { useState } from "react";
import "../styles/Footer.scss";

function Footer({
  isMusicPlaying,
  setIsMusicPlaying,
  isSoundPlaying,
  setIsSoundPlaying,
  playClick,
}) {

  // It tracks whether the "info" (likely a help section or additional information) needs to be shown.
  const [isInfoNeeded, setIsInfoNeeded] = useState(false);

  return (
    <motion.footer
      initial={{opacity: 0, y: 100}}
      animate={{opacity: 1, y: 0}}
      transition={{duration: 0.7}}
    >
      <div className="footerContainer">
        <div className="soundSection">
          <button onClick={() => {
            // setIsSoundPlaying(!isSoundPlaying);
            setIsSoundPlaying((prevSoundPlayingState) => !prevSoundPlayingState); // Better practice
            playClick();
          }}>
            {isSoundPlaying
              ? <Volume className='svg'/>
              : <VolumeOff className='svg'/>}
          </button>

          <button onClick={() => {
            // setIsMusicPlaying(!isMusicPlaying);
            setIsMusicPlaying((prevMusicPlayingState) => !prevMusicPlayingState);
            playClick();
          }}>
            {isMusicPlaying
              ? <Music className='svg'/>
              : <MusicOff className='svg'/>}
          </button>
        </div>
        <button onClick={() => {
          // setIsInfoNeeded(!isInfoNeeded);
          setIsInfoNeeded((prevInfoNeededState) => !prevInfoNeededState);
          playClick();
        }}>
              {isInfoNeeded
                ? <Cross className='svg'/>
                : <QuestionMark className='svg'/>}
        </button>
        <AnimatePresence>
                {isInfoNeeded && (
                  <MabelInfo />
                )}
        </AnimatePresence>
      </div>
    </motion.footer>
  );
}

export default Footer;
Enter fullscreen mode Exit fullscreen mode

MabelInfo.jsx:

import mabelInfo from "../assets/img/mabel-info.png";
import { motion } from "framer-motion";

function MabelInfo() {
  const variants = {
    hidden: {
      opacity: 0,
      y: 100,
      transition: { duration: 0.6 },
    },
    visible: {
      opacity: 1,
      y: 0,
      transition: { duration: 0.6 },
    },
  };

  return (
    <>
      <motion.div className="instructions"
        key="modal"
        variants={variants} // Connects the variants object we defined earlier to this element for animation control.
        initial="hidden"
        animate="visible"
        exit="hidden">
            <div>Don't click on the same card twice!</div>
            <div>Click on GRAVITY FALLS logo to go back.</div>
      </motion.div>
      <motion.img
        src={mabelInfo}
        alt="Mabel Info"
        className="mabelInfo"
        variants={variants}
        initial="hidden"
        animate="visible"
        exit="hidden"/>
    </>
  );
}

export default MabelInfo;
Enter fullscreen mode Exit fullscreen mode

Additional Information:

  • The scroll bar only appears during the popup animation.
  • I've tried applying CSS solutions but haven't found a fix.
  • Would installing any specific package help with this issue?

I've attached a screenshot of the right half of my project's start page below showing the scroll bar for reference.

Scroll Bar appears on clicking the question mark (which becomes a cross once the mabel info component pops up)

Top comments (0)