Ticket T958946
Visible to All Users

Drawer - Adopt width according to the width of the menu component

created 4 years ago

After I set the menu component to auto width, it can be displayed correctly on the big screen.

But when the screen is small, after the screen is loaded, as below:
Snipaste_2020-12-18_11-50-20.png

Click the menu button to expand the screen as below:
Snipaste_2020-12-18_11-50-43.png

The menu cannot be displayed.

How can I setting?

Answers approved by DevExpress Support

created 4 years ago (modified 4 years ago)

Thank you for informing us about these issues.

I checked your sources and found that you generated your application using the Application Template, and it uses v20.1.7.

I created an empty application using the Application Template and it works correctly in the same scenarios. See the attached 'app4.zip' file. This application uses v20.2.4.

Updated

I checked the example and found that the issue occurs because dxDrawer calculates the panel width by the child element width only on the first load. It doesn't recalculate the size of the menu after the screen size is changed or a menu item is expanded. That's why the auto setting doesn't have the desired effect in this scenario.

Unfortunately, the current dxDrawer implementation was designed to cover the fixed width only and doesn't allow us to overcome this behavior without rewriting all current styling structure/internal calculation logic from scratch. We'll consider this scenario as a possible future improvement once we decide to update the dxDrawer implementation.

As an immediate workaround, consider one of the following options:

  • display ellipsis for items with long text and implement tooltips
  • wrap item text into multiple lines

This way, you can keep the dxDrawer menu width fixed and make sure that users will be able to read long texts in dxTreeView items.

See also:

    Show previous comments (2)
    DevExpress Support Team 4 years ago

      Thank you for the modified project.
      I investigated it and found that you changed the ".side-navigation-menu" style in the "side-navigation-menu.scss" file:

      Code
      .side-navigation-menu { display: flex; flex-direction: column; min-height: 100%; height: 100%; width: auto !important;

      This was the initial "250px" value:

      Code
      width: 250px !important;

      The 'auto' value means that the width of the 'side-navigation-menu' element is equal to the width of its parent element. In Drawer, the Panel element is the parent of the 'side-navigation-menu' element and Drawer uses the 'side-navigation-menu' element width to calculate the Panel width for the 'opened' state.
      I see in your configuration that the calculated Panel width in the 'opened' state is equal to the calculated Panel width in the 'closed' state. Thus, the Panel width is not changed when you click the 'toggleMenu' button.
      The 'auto' value is incorrect in this case and an explicit width should be specified. This is a specificity of our component and we will see how to manage this case better.
      See also Drawer.maxSize.

        Hi
        After I set auto to 250px, the width cannot automatically adapt to the width of the TreeView text.

        Because I may use the API to download TreeView content of unknown character length, this feature is very important.

        Artem (DevExpress Support) 4 years ago

          Thank you for the reply, CMCIT. Dan is not online today, so I'll be happy to assist you further. I've looked through the thread and see that the main task is to adjust the Drawer side panel's size to the content width without a fixed length.

          I checked the example and found that the issue occurs because dxDrawer calculates the panel width by the child element width only on the first load. It doesn't recalculate the size of the menu after the screen size is changed or a menu item is expanded. That's why the auto setting doesn't have the desired effect in this scenario.

          Unfortunately, the current dxDrawer implementation was designed to cover the fixed width only and doesn't allow us to overcome this behavior without rewriting all current styling structure/internal calculation logic from scratch. We'll consider this scenario as a possible future improvement once we decide to update the dxDrawer implementation.

          As an immediate workaround, consider one of the following options:

          • display ellipsis for items with long text and implement tooltips
          • wrap item text into multiple lines

          This way, you can keep the dxDrawer menu width fixed and make sure that users will be able to read long texts in dxTreeView items.

          Thanks,
          Artem

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.