Ticket T1252612
Visible to All Users

How to make dxTagBox stay opened when selecting items

created 7 months ago

Hi Devextreme,

I am using your dxTagBox for performing multi select.

However there is a behaviour I am trying to implement that seems to deviate from normal usage, unless I have overseen something.

I would like the user to:

  1. Select and item.
  2. Let the tagbox stay open and immidiately display the selected items in the editor.
  3. When the user clicks outside the tag box it just closes and the selected values remains displayed.

Behaviour wise similar to the multi select from Porsche's design system, see https://designsystem.porsche.com/v3/components/multi-select/examples.

Here you can see values are immidiately added to the editors display and when the multi select closes the changes made remains.

I know that you have two modes in applyValueMode

Using instant immidiately closes the dropdown and this i what I am trying to avoid.

Using the useButtons keeps the dropdown open and also displays two buttons to confirm/cancel. This is fairly close to what I am trying to acheive with the difference being that 1) It does not change the values on the fly as the user selects/unselects items and 2) It needs button confirmations.

I hope my question is somewhat clear of what I am trying to acheive :)

Thanks,
Jeppe

Answers approved by DevExpress Support

created 7 months ago

Hi,

Thank you for the description.

Currently, TagBox does not offer a built-in solution for this behavior. However, you can consider the following workaround:

  • Continue using applyValueMode set to 'instantly'.
  • To prevent the dropdown from closing by default, define a custom itemTemplate and implement the desired click logic within it, including stopPropagation. This will override the default click behavior.

For reference, you can view a simple demo that I created: Demo Link.

Please let me know if this helps.

    Show previous comments (2)
    PD PD
    Paul Donato (DevExpress Support) 3 months ago

      Hi,

      Thank you for the update.

      Upon further checking, you can skip the workarounds and instead enable the showSelectionControls for your usage scenario.

      Please accept my apologies for overlooking this solution earlier.
      See the following example: CodeSandBox

      Let me know if this helps or if you have further questions.

        Hi Paul,

        It's fine - it's a much simpler solution :D

        So far everything seems to be working as I would like, thanks.

        PD PD
        Paul Donato (DevExpress Support) 3 months ago

          Hi,

          Thank you for the update.

          I'm happy to hear that the alternative solution works well for you. If you need further assistance, feel free to contact us.

          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.