Tips for showcasing overflowing text in a menu list by rotating the item text

Imagine you have a TextMenuItem component, using MenuItem from the Material-UI library, that is part of a chain consisting of DropDownSearch > SimpleListMenu > FixedSizeList > TextMenuItem. In simple terms, this creates a searchable dropdown element with text items.

However, when the text within the FixedSizeList container is too long, the overflow is hidden making it difficult to read the entire text.

What can be done in this situation? The proposed solution by the Product Manager was to display the full text outside the menu structure, but that doesn't seem like the right approach.

Is there a way, perhaps on mouse hover, to rotate or spin the text so that the content of the menu item can be viewed without the need for an additional pop-out display?

export type TextMenuItemType = FunctionComponent<ITextMenuItemProps>;
const TextMenuItem: TextMenuItemType = (props) => {
  const { text, selected, onSelect } = getTextMenuItemProps(props);
  const styles = useTextMenuItemStyles();

  return (
    <MenuItem sx={styles.container} selected={selected} onClick={onSelect}>
      <Typography sx={styles.label}>{text}</Typography>
    </MenuItem>
  );
};

const useTextMenuItemStyles = () => {
  return css({
    container: {
      minHeight: 'auto',
    },
    label: {
      whiteSpace: 'nowrap',
      overflow: 'hidden',
      textOverflow: 'ellipsis',
    },
  });
};

Answer №1

The following CSS was implemented to create a rotating text effect on hover, but it's not perfect as it rotates regardless of the input size. It would be better if it only rotated when the content overflows.

It's not the ideal solution, so I am searching for a better one.

    container: {
      minHeight: 'auto',
      overflow: 'hidden',
    },
    label: {
      whiteSpace: 'nowrap',
      overflow: undefined,
      overflowWrap: 'break-word',
      '@keyframes scrollText': {
        '0%': { transform: 'translate(0%, 0)' },
        '100%': { transform: 'translate(-100%, 0)' },
      },
      '&:hover': {
        animation: 'scrollText 4s linear infinite',
      },
    },

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for accessing the value from an input field in an AngularJS application

Looking at my DOM structure below, <input class="k-textbox ng-pristine ng-untouched ng-valid ng-valid-required" type="text" placeholder="" ng-blur="controller.isDirty=true" ng-change="controller.isDirty=true" ng-model="controller.model.value" ng-requir ...

Unveiling the Secrets of Encoding and Decoding JSON within a Concealed HTML

I am in the process of creating a unique control using HTML and JQuery that will showcase a specific text value. Users will have the ability to input various key/value pairs. Here is the current code snippet I am working with: <input id="keyValue" type ...

Understanding the status of a modal: When it's open, when it's closed - decy

When using the MUI Modal component, the onClose callback is triggered when the modal begins to close. However, there is an animation with a delay before the modal actually closes. I am looking for a way to execute a callback after the animation has finis ...

Developing a table with JavaScript by parsing JSON data

Starting off, I am relatively new to working with JavaScript. Recently, I attempted to generate a table using data from a JSON file. After researching and following some tutorials, I successfully displayed the table on a web browser. However, I noticed tha ...

Issue with displaying jqplot in a jQuery page

Currently, I'm utilizing jqmobile pages for switching between various pages in an html5 application. One of these pages features a jqplot chart. Below is the code snippet: <div data-role="page" id="page-two" data-title="Page 2"> &l ...

Server-side Data Fetching with Nuxt.js

Is there a method to exclusively retrieve data from an API on the server-side in NuxtJS due to me needing to include my API_TOKEN in the request headers? Sample Code: <template> <div> <h1>Data obtained using asyncData</h1> ...

CSS Flexbox: Dealing with Overlapping Flex Items on Narrow Screens

Hey there! I've successfully created a custom timeline using flexbox, but I'm encountering an issue on smaller screens. As the window size decreases, the flex items start to overlap. Is there a way you can assist me in adding some space without d ...

Tips for transferring data between two forms in separate iFrames

I'm trying to achieve a functionality where the data entered in one form can be submitted to another form within an iframe. The idea is to allow visitors to preview their selected car in the iframe, and if satisfied, simply press save on the first for ...

Bring in Event Types from React using TypeScript

Is there a way to import Event Types from React and use them in Material-ui? Specifically, I am looking for guidance on how to import KeyboardEvent so that it can be utilized for onKeyDown callback type annotation. I have examined the .d.ts file of Mater ...

The padding of elements changes accordingly as the dimensions (width/height) of the header are adjusted

Currently, I'm tackling the challenges of working on my website and trying to understand JavaScript better. I am facing an issue where I want my aside menu's padding to adjust when my header shrinks in height. Furthermore, at the end of the web ...

a height of 100% with a minimum height of 100%

Is there a way to make the third and fourth rectangles have the same position while filling all the remaining height in %? Keep in mind that we can't change the min-height:100% on the body or html. Feel free to use CSS and HTML for your code solution. ...

Using Django to load a template and incorporate a loading spinner to enhance user experience during data retrieval

In my Django project, I need to load body.html first and then dashboard.html. The dashboard.html file is heavy as it works with python dataframes within the script tag. So, my goal is to display body.html first, and once it's rendered, show a loading ...

Unable to use .ajax within autocomplete function

I've been struggling for days to make the jQuery autocomplete feature work. Currently, I am able to type in the textbox and see exactly what I want, but the issue arises when I click on the desired option - it does not show up in the textbox. I suspec ...

How do I customize the border color for the Select component in Material UI?

I have been working on customizing the Select component provided by Material UI. Here is a visual representation of what it currently looks like: https://i.stack.imgur.com/YGheB.png My goal is to change the border-color of the select component from the ...

Specify the versions of packages in your package.json file

My package.json file contains many dependencies with "*" as the version, which I have learned is not recommended. I want to update them all to their latest versions. Despite using npm-check-updates tool, it indicates that all packages are up-to-date. Can ...

What is the best way to redirect before displaying a page in Next.js?

Is it possible to redirect a user before rendering a page in Next.js? Currently, my code looks like this: import { useRouter } from 'next/router'; export default function RedirectPage() { const router = useRouter(); router.push('/p ...

Do I need to make any changes to the application when adding a new couchbase node to the cluster

Currently, I am utilizing the Node.js SDK to establish a connection with a couchbase cluster. Despite this, in the Node.js documentation, there is no clear instruction on how to input multiple IP addresses (of cluster nodes) when creating the cluster objec ...

Unable to set CSS image as background

Currently, I am in the process of developing a website using HTML 5, CSS, and JavaScript. However, I am encountering an issue with image manipulation on the site. I am attempting to make the image the background but every method I try seems to be lacking a ...

Enhance your user interface with a personalized IconButton, complete with variant properties similar to those of a

Apologies in advance for any oversights as this is my debut post... My job requires the use of Material UI, and I need an IconButton that mimics the style of a Button. I was able to achieve this by directly copying the Mui Component from here. However, ...

A TypeScript method for accessing deeply nested properties within an object

I'm currently working on a function that utilizes typings to extract values from a nested object. With the help of this post, I managed to set up the typing for two levels successfully. However, when I introduce a third (known) level between the exis ...