question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modals styling issues when using @mantine/remix

See original GitHub issue

What package has an issue

@mantine/modals

Describe the bug

Steps to reproduce:

  • I started with mantine-remix-template
  • I added @mantine/modals to package.json
  • In root.tsx I added ModalsProvider
<ModalsProvider
  modalProps={{ centered: true }}
>
  <Outlet />
</ModalsProvider>
  • I added this code to index.tsx
import { Text, Button, Stack } from '@mantine/core';
import { openConfirmModal } from '@mantine/modals';

export default function Index() {
  const openModal = () =>
    openConfirmModal({
      title: 'Please confirm your action',
      children: (
        <Text size="sm">
          This action is so important that you are required to confirm it with a modal. Please click
          one of these buttons to proceed.
        </Text>
      ),
      labels: { confirm: 'Confirm', cancel: 'Cancel' },
      onCancel: () => console.log('Cancel'),
      onConfirm: () => console.log('Confirmed'),
    });

  return (
    <Stack align="center" mt={50}>
      <Text size="xl" weight={500}>
        Welcome to Mantine!
      </Text>
      <Button onClick={openModal}>Click the button</Button>
    </Stack>
  );
}

While the modal looks good in dev mode, after a yarn build + yarn start the styles are off: Screenshot 2022-09-01 at 13 54 11

What version of @mantine/hooks page do you have in package.json?

5.1.0

If possible, please include a link to a codesandbox with the reproduced problem

No response

Do you know how to fix the issue

No

Are you willing to participate in fixing this issue and create a pull request with the fix

Yes

Possible fix

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:7
  • Comments:19 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
Beardlesscommented, Sep 6, 2022

Hi, @rtivital I have a problem with React 18 and Remix.

Trying to use your example of integrating Mantine into Remix, but Remix is using now renderToPipeableStream instead of renderToString. And I don’t know where to put injectStyles method as I don’t have a markup to use it.

This is an example code you will get after initialization of the new remix app entry.server.tsx:

export default function handleRequest(
  request: Request,
  responseStatusCode: number,
  responseHeaders: Headers,
  remixContext: EntryContext
) {
  const callbackName = isbot(request.headers.get("user-agent"))
    ? "onAllReady"
    : "onShellReady";

  return new Promise((resolve, reject) => {
    let didError = false;

    const { pipe, abort } = renderToPipeableStream(
      <RemixServer context={remixContext} url={request.url} />,
      {
        [callbackName]: () => {
          const body = new PassThrough();

          responseHeaders.set("Content-Type", "text/html");

          resolve(
            new Response(body, {
              headers: responseHeaders,
              status: didError ? 500 : responseStatusCode,
            })
          );

          pipe(body);
        },
        onShellError: (err: unknown) => {
          reject(err);
        },
        onError: (error: unknown) => {
          didError = true;

          console.error(error);
        },
      }
    );

    setTimeout(abort, ABORT_DELAY);
  });
}
1reaction
alukachcommented, Oct 21, 2022

For the record, removing the ClientProvider brings up the following hydration bugs for me:

Reproducible example found here: https://github.com/alukach/mantine-remix-rendering-issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Considerations for Styling a Modal | CSS-Tricks
It's tempting to use an overflow value right on the .modal itself, but there are two problems with that: We might want some...
Read more >
Bootstrap 3 modal fires and causes page to shift to the left ...
Fixing the shifting left issue is easily done using CSS alone. ... have fixed navbar and dont want to scroll body to top...
Read more >
Working with Bootstrap's Modals in React | Pluralsight
After the installation is complete, you can import the modal component and the styling into your module. 1import Modal from "react-bootstrap/ ...
Read more >
Modal · Bootstrap v4.5
Modals are built with HTML, CSS, and JavaScript. · Clicking on the modal “backdrop” will automatically close the modal. · Bootstrap only supports...
Read more >
W3.CSS Modal - W3Schools
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found