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

TagInput - Functional component for tag-like inputs #3735

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Commits on Sep 17, 2024

  1. Initial commit: Rename component, set basic structure

    No actual functionality implemented yet, just renames the component from "StringArrayEditor" to "TagInput", for brevity at the possible cost of clarity.  For now, the original StringArrayEditor is kept and named "TagInput-class.jsx" so that I can reference it as I work on the functional component.
    Gazook89 committed Sep 17, 2024
    Configuration menu
    Copy the full SHA
    e8e16f4 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ea7f18e View commit details
    Browse the repository at this point in the history

Commits on Sep 18, 2024

  1. Render element for each value from props

    Take an array of values from props, load it into valueContext state with an "editing" boolean for each value.  Then, when rendering the component, take each value in the valueContext array and create a div for each --
    
    at this point, if the value is "being edited", it returns a div with text "editing".  If not being edited, it returns a div with the value as text.
    
    Nothing is being edited at this point since that functionality doesn't exist yet.
    Gazook89 committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    d505e4e View commit details
    Browse the repository at this point in the history
  2. Render tags as "write" or "read"

    Tags are now either "readTag" or "writeTag", with the former being a div with the tag value and the latter a text input with the value.
    
    Minor class name change in LESS.
    Gazook89 committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    d5c5b43 View commit details
    Browse the repository at this point in the history
  3. Add click handler for readTags to open text input

    Clicking on a readTag now converts that tag to a text input, and maintains the tag value.  It also closes any other open text inputs amongst the tags (but leaves the "new tag" input open).
    Gazook89 committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    36aa4ea View commit details
    Browse the repository at this point in the history

Commits on Sep 19, 2024

  1. add editing of input functionality

    Currently uses uncontrolled inputs with a `defaultValue` attribute set to the values passed in via props.  The input can then be edited, and when `Enter` is pressed, it updates the stored value state.  Later, this can be updated to be trigger with `Tab` or clicking outside the active input element.
    Gazook89 committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    c5033db View commit details
    Browse the repository at this point in the history
  2. Add in handlers for TagInput value changes

    Now brew metadata is actually updated and preserved across reloads to match updated tag values.  useEffect calls the props.onChange event from the parent component on every change to the valueContext state of this component (right now, after hitting Enter in a tag input).
    Gazook89 committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    d1686c4 View commit details
    Browse the repository at this point in the history
  3. Add method for adding new tags

    Component now accepts new tags entered in the always-present input field.  Entering a value and hitting Enter submits the tag, and it appears as a new tag.
    
    Updated the tag list keys to be unique (via `index`).
    
    To-Do: empty 'new tag' input after submitting.
    Gazook89 committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    70a3cb9 View commit details
    Browse the repository at this point in the history
  4. Add 'remove' button and method

    New button that triggers `submitTag()` method directly (rather than throw onKeyDown event) and passes `null` as the newValue.  New `if` condition checks for null on newValue and if true, removes the tag that matches the originalValue.
    
    This *does* currently delete all duplicate tags if they match the one you are deleting.  Not sure when you'd ever want duplicate tags, but regardless i'll likely switch this to work via Index, not value.
    Gazook89 committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    c65210b View commit details
    Browse the repository at this point in the history
  5. Use index to find and remove tags

    Fixes issue in last commit, so removing a tag that has duplicate value of other tags only removes the correct one, not the others as well.
    Gazook89 committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    c1288ce View commit details
    Browse the repository at this point in the history
  6. Set new tag input to clear itself after submission

    Now whenever a new tag is submitted, the input element is cleared and ready for the next tag.
    
    Whitespace cleanup.
    Gazook89 committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    a54adc1 View commit details
    Browse the repository at this point in the history
  7. Add comma to "submit" buttons

    Now comma (`,`) submits a tag, like `Enter`
    Gazook89 committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    5b4a7c1 View commit details
    Browse the repository at this point in the history
  8. Adjust html structure to handle tags as list

    Begin work on setting a better html structure for the component.
    
    Create a .less file for the component, which I may not actually use.
    Gazook89 committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    7ea1696 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    8a67e1e View commit details
    Browse the repository at this point in the history
  10. Fix multiple duplicate tags updating at once

    Fixes an issue where tags with duplicate values would all update to the same value after editing just one.
    
    Also an adjustment to the parameters that are passed to handleInputKeyDown-- they are now one object.  This helps handle an "options" object where more optional features can be turned on and off.
    Gazook89 committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    b585e85 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    10a9bc2 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    433f016 View commit details
    Browse the repository at this point in the history

Commits on Sep 23, 2024

  1. Configuration menu
    Copy the full SHA
    a9b6d5f View commit details
    Browse the repository at this point in the history
  2. remove tagInput-class

    This file was just the old StringArrayEditor that I kept around for easy reference.  Can be deleted now.
    Gazook89 committed Sep 23, 2024
    Configuration menu
    Copy the full SHA
    5af45f1 View commit details
    Browse the repository at this point in the history

Commits on Sep 24, 2024

  1. Variable name changes for clarity

    Followed suggestions on the PR.
    Gazook89 committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    a96ff6e View commit details
    Browse the repository at this point in the history