Search code examples
cssreactjswebkitoverflowaws-amplify

Macbook Safari is displaying hidden/ overflow text as stacked


I am using Amplify UI in a React Library and making cards that show users and some of their info. However, if they have too much info, the overflow is cut off and can be seen on another page. Everything looks fine except on some user's Macbooks. I'm a so confused because not even Iphones have been having this issues.

Here is what the user card is supposed to look like: Good CArd

But it ends up looking like this on some people's MacBooks:

Stacked Info

Please ignore the red marker for personal information.

Here is what I do to call the component that Amplify generates from my figma code:

                  Bio: {
                    overflow: "fade",
                    style: {
                      WebkitOverflowScrolling: "touch", // for webit browsers to prevent stacked letters
                      whiteSpace: "nowrap",
                    },
                    maxHeight: "80px",
                    fontSize: { base: ".875rem", medium: ".875rem" },
                  },
                  Subjects: {
                    alignItems: "flex-start",
                    overflow: "clip",
                    style: {
                      WebkitOverflowScrolling: "touch", // for webit browsers to prevent stacked letters
                      whiteSpace: "nowrap",
                    },
                    maxHeight: "60px",
                    wrap: "wrap",
                    gap: "xs",
                    alignContent: "flex-start",
                  },

and here is a snippet of the generated component code from Amplify:

<Flex
          gap="4px"
          direction="row"
          width="unset"
          height="unset"
          justifyContent="flex-start"
          alignItems="center"
          shrink="0"
          position="relative"
          padding="0px 0px 0px 0px"
          children={subjects}
          {...getOverrideProps(overrides, "Subjects")}
        ></Flex>
...
<Text
          fontFamily="Inter"
          fontSize="16px"
          fontWeight="400"
          color="rgba(48,64,80,1)"
          lineHeight="24px"
          textAlign="left"
          display="block"
          direction="column"
          justifyContent="unset"
          width="unset"
          height="unset"
          gap="unset"
          alignItems="unset"
          shrink="0"
          alignSelf="stretch"
          position="relative"
          padding="0px 0px 0px 0px"
          whiteSpace="pre-wrap"
          isTruncated={true}
          children={tutor?.bio}
          {...getOverrideProps(overrides, "Bio")}
        ></Text>

is there something else I can add to these containers to make MacBook safari now show the stacked information?


Solution

  • This is most likely because overflow: clip is not supported on Safari Desktop on version 15 or lower. Users who have not updated their base Mac OSX operating system recently will be on these versions (on Mac, safari versions are tied to the OS version).

    clip behaviour is similar to hidden. This may or may not display correctly but try changing:

                      Subjects: {
                        alignItems: "flex-start",
                        overflow: "clip",
                        style: {
                          WebkitOverflowScrolling: "touch", // for webit browsers to prevent stacked letters
                          whiteSpace: "nowrap",
                        },
                        maxHeight: "60px",
                        wrap: "wrap",
                        gap: "xs",
                        alignContent: "flex-start",
                      },
    

    To:

                      Subjects: {
                        alignItems: "flex-start",
                        overflow: "hidden",
                        style: {
                          WebkitOverflowScrolling: "touch", // for webit browsers to prevent stacked letters
                          whiteSpace: "nowrap",
                        },
                        maxHeight: "60px",
                        wrap: "wrap",
                        gap: "xs",
                        alignContent: "flex-start",
                      },