Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to swap out single option #176

Closed
Snailedlt opened this issue Nov 25, 2022 · 4 comments
Closed

Ability to swap out single option #176

Snailedlt opened this issue Nov 25, 2022 · 4 comments
Labels
discussion Gathering feedback on open questions enhancement New feature or request UX User experience

Comments

@Snailedlt
Copy link
Contributor

Snailedlt commented Nov 25, 2022

Problem

At the moment it's impossible to swap out a single option in the middle of the options list. This can be troublesome for applications where the order matters.

Example of problem

Take this example:
I have the following options selected:

["Python","TypeScript","C","Dart","Elm"]

Now I want to swap out C with CoffeeScript, and keep the sorting. So I want the options list to change to this:

["Python","TypeScript","CoffeeScript","Dart","Elm"]

In order to do this atm, I would have to delete all options after C, and C itself, then add CoffeeScript and re-add the other options in the correct order. This is not ideal, but not such a big issue in this case. However, the more options there are after the one we want to change, the more tedious and error-prone this approach gets. Imagine having to delete and re-add 40 options, it would be impossible without saving an image of the previous setups somehow.

Solution

To fix this, I suggest that we add input fields to the clicked option on click. So If I click on C, it should replace the C option with an input field. This input field will then be used to search for the replacement for C. If I click out of the dropdown C should still be selected, but if I choose another option in the list, then C should be replaced by that option.

Start state

["Python","TypeScript","C","Dart","Elm"]

Clicking on C

image

After clicking, the dropdown menu opens up, and C is turned into an input field. In the dropdown list, C is highlighted to clearly show that it was the previously selected option.

image

Clicking on CoffeeScript

image

After clicking on CoffeeScript, the input field is replaced with CoffeeScript

image

End state

["Python","TypeScript","CoffeeScript","Dart","Elm"]
Code used in this example ```html
  • C C
  • ```
    alternative styling ![image](https://user-images.githubusercontent.com/43886029/203946715-750cb6ad-0d3e-4be0-9dae-f5f3e42332c6.png) ![image](https://user-images.githubusercontent.com/43886029/203946719-9faf1e90-d7c1-40da-8152-d7da49931295.png)

    More Info

    Now if we do this, the input field at the end of the multiselect will be obsolete for single-select configurations. Therefore it makes sense to conditionally render it based on this if

    if(maxSelect > 1 && options.length > 1) {
        // Render input field after selected options
    }

    This will also fix #174

    Acceptance Criteria

    For illustrative purposes I'll be using C as the previously selected option, and CoffeeScript as the option we want to replace it with.

    1. Clicking on an option replaces the option (C) with an input field which is automatically focused.
    2. When the input field is focused, the normal dropdown list opens up.
    3. The previously selected option (C) should be visible at the top of the list, and highlighted.
    4. If the user exits the dropdown, the previously selected option (C) should replace the input again. Returning the multiselect to the same state as before.
    5. If the user selects a different option (Erlang) from the dropdown. Then the input field should be replaced with said option (Erlang).
    6. If only one option is selected, then the input field at the end should not be rendered
    @janosh
    Copy link
    Owner

    janosh commented Nov 25, 2022

    Would it solve your use case to allow selected options to be draggable?

    @janosh janosh added enhancement New feature or request awaiting user Needs more information from OP. UX User experience labels Nov 25, 2022
    @Snailedlt
    Copy link
    Contributor Author

    @janosh hmm, kinda, but not the linked issue. Drag and drop sounds cool, but I kinda still prefer this suggested solution over it if I were to choose. But maybe both? 😅

    @janosh
    Copy link
    Owner

    janosh commented Nov 25, 2022

    @janosh ...but I kinda still prefer this suggested solution over it if I were to choose. But maybe both? 😅

    I don't see much added value in turning each selected option into its own on:click input. We can leave this issue open for now to see if anyone wants this enough to make a PR. If that PR doesn't break anything and looks good UI-wise, I'm happy to merge it.

    @janosh janosh added discussion Gathering feedback on open questions and removed awaiting user Needs more information from OP. labels Nov 25, 2022
    @janosh
    Copy link
    Owner

    janosh commented Feb 14, 2023

    Closing this as not planned since I've heard no further requests/complaints in this area. I think having draggable selected options solves this problem well enough.

    @janosh janosh closed this as completed Feb 14, 2023
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    discussion Gathering feedback on open questions enhancement New feature or request UX User experience
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants