themesberg / themesberg/flowbite-react

Modals buggy on mobile

Open
#1,083 1 comment 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

:bug: bug confirmed help wanted
Dominant language
TypeScript
Stars
2.1k
Forks
506
PR merge metrics
No merged PRs in 30d

Description

  • I have searched the Issues to see if this bug has already been reported
  • I have tested the latest version

Steps to reproduce

I have found multiple issues with the default flowbite-react modals when viewed on mobile. I initially found these issues in my own app and then later discovered they are also broken on the official flowbite-react docs website.

  1. Go to: https://www.flowbite-react.com/docs/components/modal on any browser in mobile
  2. Click on any of the Toggle Modal buttons

Current behavior

IMG_4770

  • a. The modal appears so high up that the close "X" button is not visible, making some of the modals in the examples screen unclosable
  • b. The modals do not appear centred by default (I could understand this is a stylistic decision, but it's a bit strange to have pop-ups appear at the top of the screen)
  • c. If you go into developer tools and add lots of extra text to one of the modals, you will see it will expand so far below down to the screen that the padding & rounded corners of the modal dissappear on the bottom. This only happens on chrome & safari.

Expected behavior

  • I would expect Modals to be fully visible and centred by default, and not require theme overwrites to accomplish this.
  • I would expect the padding around the modal to always be visible even as the content of the modal grows.

Context

Environments:

  • Tested on iOS devices using chrome, firefox & safari
  • Tested in an android emulator using only chrome
  • Issue not present on desktop, and also not on desktop when using the "Responsive Design Mode", only happens on-device

Fix suggestions:

I was able to solve these problems in my app with the following theme override:

theme={{
  root: {
    // Replace: h-modal h-screen with h-full
    base: 'fixed top-0 right-0 left-0 z-50 h-full overflow-y-auto overflow-x-hidden md:inset-0 md:h-full',
  },
  content: {
    // Added: flex flex-col justify-center
    base: 'relative h-full w-full p-4 md:h-auto flex flex-col justify-center',
    // Added: max-h-full max-w-full overflow-hidden
    inner: 'relative rounded-lg bg-white shadow dark:bg-gray-700 flex flex-col',
  },
}}

Hope this helps!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/components/Modal/theme.ts at the referenced root and content styles, then reproduce the modal behavior on the Flowbite React modal documentation page using a mobile browser. Verify that modals remain centered, closable, and retain visible padding and rounded corners as content grows across the reported mobile browsers.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, tailwindcss, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.