Add the remove button to poll choices

Created on 3 December 2016, over 7 years ago
Updated 13 March 2024, 4 months ago

Problem/Motivation

When the user adds an answer it is possible to remove the answer by deleting its contents, but this is not intuitive. It also does not follow commonly understood patterns.

Proposed resolution

Follow the common pattern by providing an 'X' icon (button) to the right of each answer field that would have the following behaviors:

  1. If there is an empty field clicking the 'x' removes the field.
  2. If there is a populated field clicking the 'x' removes both the field and its contents.
  3. If there is a populated field and the user deletes the contents of the field, on blur trigger the same event as clicking the 'x" and remove the field.
  4. Do not display an 'x' button on the last-child field since that is the placeholder for the next item.
  5. If the user populates the field that is the last child, add the 'x' button.
  6. If the user populates the field that is the last child, on blur, automatically trigger the "add another" behavior, add another field.
  7. Remove the draggable class from the last child field so that users can't move the empty placeholder field between other fields, or move populated fields.

Remaining tasks

Write patch

User interface changes

?

API changes

?

Data model changes

✨ Feature request
Status

Active

Version

2.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States tkoleary

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡§πŸ‡ͺBelgium BramDriesen Belgium πŸ‡§πŸ‡ͺ

    Drupal core is now adding a "remove" button on multivalue field items. (Not sure if this was a thing 7 years ago 😁).

    I have no objections to see how we can add the remove button to our entity. Would be great to update the validation logic then to also trigger a warning when you're deleting a poll choice which has votes.

  • πŸ‡§πŸ‡ͺBelgium BramDriesen Belgium πŸ‡§πŸ‡ͺ

    Uploaded screenshot example.

Production build 0.69.0 2024