plone / volto

React-based frontend for the Plone Content Management System
https://demo.plone.org/
MIT License
431 stars 579 forks source link

Add Field modal when editing a content type schema needs resizing. #4058

Open flipmcf opened 1 year ago

flipmcf commented 1 year ago

Describe the bug The "Add Field" modal when editing a content type schema is cut off - Select box is too large for window.

To Reproduce From the control panel -> content types (localhost:3000/controlpanel/dexterity-types )

Edit the schema of any content type (three dots at the end of the row, select 'schema')

Click "select" in the type drop-down.

Note that the list is cut off, and the user must scroll the main window to see the last few choices.

Expected behavior The main modal shouldn't scroll. Only the dropdown should scroll. You shouldn't have to use 2 scroll bars to get to the "yes / no" field choice.

Screenshots select_too_long

Software (please complete the following information):

MAX-786 commented 1 year ago

Hello @flipmcf 😊, I think somehow we can reduce the height of the internal (select) component so it fits with an outer view. If you haven't started working on this, I would like to work on this too.

JeffersonBledsoe commented 1 year ago

I find this behaviour happens in a few places in Volto. The dropdown always appears to display below the cursor and is contained within the parent of whatever triggered the dropdown, causing you have to scroll the parent to be able to then scroll the dropdown to see the bottom of the list. Looking at the ReactSelect docs (which is what is used for the popups), it looks like there's a menuPlacement prop that we could use. It defaults to bottom but there's an auto value that seems to do the moving behaviour I'd like to see! Also has portal support for rendering it outside of the parent. Could be a useful PR!

danalvrz commented 1 year ago

I implemented the suggested change, by assigning the value auto to the prop menuPlacement in the SelectWidget component, but the issue seems to persist.

https://user-images.githubusercontent.com/89805481/207117409-5a5dfb4c-0f16-4cc9-8744-e12b05b75f64.mov

victorchrollo14 commented 4 months ago

hey @flipmcf , @JeffersonBledsoe.

Adding a maxMenuHeight="10em" prop to the Select component in SelectWidget would fix the issue. But I'm not sure if it is a good fix, as the SelectWidget component is used in a lot of other components as well. And it would prevent those components from having the drop-down menu height of greater than 10em.

<Select
          id={`field-${id}`}
          key={choices}
          name={id}
          menuShouldScrollIntoView={false}
          isDisabled={disabled}
          isSearchable={true}
          className="react-select-container"
          classNamePrefix="react-select"
          isMulti={isMulti}
          options={options}
          styles={customSelectStyles}
          theme={selectTheme}
          maxMenuHeight="10em"
          menuPlacement="bottom"

https://github.com/plone/volto/assets/89346667/d7f11637-ccf0-40f2-98f1-70de949c05f5

stevepiercy commented 4 months ago

Maybe portaling option?

victorchrollo14 commented 3 months ago

Yeah portalling options works as well. we can add menuPortalTarget={document.body} prop to the select component. and add

menuPortal: (base) => ({ ...base, zIndex: 9999 }), 

to customSelectStyles in /widgets/SelectStyling.jsx. This seems to be work fine and doesn't break things in other places the component is used in.

Screencast from 08-03-24 05:51:57 PM IST.webm

stevepiercy commented 3 months ago

@victorchrollo14 would you be willing to create a PR for this implementation? It looks good.

victorchrollo14 commented 3 months ago

Yeah, I'll make a Pr for it.

victorchrollo14 commented 3 months ago

hey @stevepiercy. I ran the tests using pnpm test. The SelectWidget test was failing, then there was an option to update the SelectWidget snapshots, and I updated it, and the test stopped failing. now I have changes in 4 files.

I have run pnpm test and pnpm lint, Is there anything else to run before making the commit. should I run this one as well (https://6.docs.plone.org/volto/contributing/acceptance-tests.html) .

stevepiercy commented 3 months ago

@victorchrollo14 I'm not a Volto developer. I just do issue triage and documentation for Volto. I think you're on the right path and have satisfied most if not all requirements. When you create a PR, GitHub workflows will run and let you know if you missed anything.

victorchrollo14 commented 3 months ago

Ok. Thank you