Create a React MUI component that allows menu items to become sticky when selected

Is there a way to make the mui MenuItem stay sticky to Select while scrolling down?

To see the issue in action, check out this codesandbox example https://codesandbox.io/s/quirky-knuth-5hr2dg?file=/Demo.tsx

Simply click on the select and start scrolling down. Notice how the menu items move down while you scroll, but I would like them to stay fixed with the select element. Ideally, as I scroll down, the menu items should move up and eventually disappear just like the select does.

Answer №1

The options on the menu are enclosed in a dialogue box marked with the unique identifier menu-. The dialogue is configured to maintain a position of fixed, ensuring it remains on screen while scrolling. To produce this outcome, utilize the subsequent CSS class:

#menu- {
  position: absolute;
}

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

What is the best way to eliminate unnecessary whitespaces from the className attribute in React using eslint and prettier?

I encountered an issue while working on React projects. It seems that prettier does not address the problem of unnecessary whitespaces in classNames. For instance: <img className='hidden lg:block ' src='./images/image-product-des ...

AngularJS is encountering an issue where it cannot locate the App Module

Whenever I attempt to execute this code, I encounter errors. Below is the code followed by the error message: index.html: <!DOCTYPE html> <html> <head> <meta id="meta" name="viewport" content="width=device-width, initial-scale=1 ...

Managing key presses with functions in VueJs

Within my component, I am utilizing VueStrap's modal in the following manner: <template> <modal-window v-model="show" v-on:keyup="keyHandler($event)" @ok="submit()" @cancel="cancel()" @closed=" ...

Encountered a JSON error while implementing in an ASP project

Currently, I am working with JavaScript and C# in aspnet. My goal is to pass 3 values from the Asp Page to the code behind, using the Json method. Below is how I achieve this: //initialize x, y and nome var requestParameter = { 'xx': x, 'yy ...

Creating a side by side Material-UI React List

Looking for some guidance on aligning lists in material UI within a react project. Any suggestions? <Typography><strong>Symptoms</strong></Typography> <ul> <h5>Common:</h5> <ul class ...

Is it possible to exclusively render meta tags as SSR on my website?

My website is fully developed using React for the frontend and NodeJs + Express for the backend. I am looking to implement dynamic OG (Opengraph) Tags for a specific route that is used by a specific component. Converting this component to SSR may be chall ...

Ways to invoke a function within a React Material-UI component

Currently, I am in the process of setting up a chat system that allows users to add emojis. To achieve this feature, I have devised a function that produces a component containing both text and an image. Here is the function I have implemented: test: fu ...

The top margin is experiencing issues and is not functioning correctly

I'm struggling to identify the problem with this script: http://jsfiddle.net/AKB3d/ #second { margin-top:50px; ... } My goal is to have the yellow box positioned 50px below the top border of the right box. However, every time I add margin-top to ...

Updating NavBar text dynamically based on user login status in React.JS

Within my project, there is a Navigation bar that I access from App.js. Depending on whether I am logged in or not, I want to display different versions of the NavBar. When logged in, the NavBar should have a logout button. And when logged out, it should s ...

Using jQuery to send information to PHP via an AJAX request

When attempting to use jQuery to send form data to a PHP file, nothing happens when the button is pressed. The jQuery code snippet: $(document).ready(function(){ $("#daily_user_but").click(function(){ $('#result').html('<im ...

Conquering cross-origin resource sharing (CORS) using XMLHttpRequest without relying on JSONP

Appreciate your time in reading this inquiry! For the past few days, I've been grappling with an AJAX request issue. Despite scouring through numerous answers on Stack Overflow, I'm still unable to find a resolution. Any assistance would be grea ...

Is there a way to smoothly navigate back to the top of the page after the fragment identifier causes the page to scroll down?

I do not want to disable the functionality of the fragment identifier. My goal is for the page to automatically scroll back to the top after navigating to a specific section. This inquiry pertains to utilizing jQuery's UI tabs. It is crucial to have ...

NextJS fails to load on iPhones connected to cellular data

I recently completed the development of a NextJS web application using React on my MacBook Air M1. After compiling a Docker image to ensure compatibility with amd64 processors, I deployed it to an AWS EC2 instance running Ubuntu 20.04 on an x86_64 processo ...

Steps for eliminating a button when the API no longer provides any information

Everything is functioning smoothly with the code below, but I would like to enhance it so that when I call getNextPers() and there is no information available, the Ver Mais button disappears. I have been researching solutions without success, so any assi ...

Pop-up windows, the modern day digital version of fortune cookies

Expressing my requirement might be a bit challenging, but I will do my best. My goal is to create a web application using ASP.Net with C#. This project calls for functionality similar to the Windows popup: When a user clicks on the favorite button in IE- ...

Implementation of Material UI Autocomplete feature with options consisting of an array of objects linking to both ID and label properties

Utilizing the Material UI Autocomplete component in my project has been a key feature. Referencing the official documentation, here are the available options: let options = [ { id: "507f191e810c19729de860ea", label: "London" }, { id: "u07f1u1e810c19 ...

Auto-fit HTML Webpage Resizer Simplified

Just finished my very first jQuery project, a simple full-width slider. I've been focusing on HTML & CSS and currently working with C#. The problem is that I don't want the page to be scrollable; I want it to autofit to the webpage. Imagine ope ...

Customize the appearance of a hyperlink

I am having difficulty styling a link's title using jQuery-mobile. Each link represents a player with unique abilities. When the user hovers over a player, I want a tooltip to display their special ability. Despite trying various code samples, none ha ...

simultaneous image hover effect for all images

I am experiencing an issue with my CSS and Bootstrap hover effect. The overlay tags are enclosed within a div class, but they all hover simultaneously. Each overlay belongs to a different Bootstrap grid, yet the effect extends even to the empty spaces betw ...

What is the reason behind a taller button when using a single line span?

Currently experiencing some strange effects with the radio buttons I'm working on. My goal is to have them all be the same size, but they are coming out different depending on whether the text within the button spans one or two lines. I've been a ...