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

ImageManager tag filter have wrong initial state #932

Open
jumbosushi opened this issue May 9, 2019 · 0 comments
Open

ImageManager tag filter have wrong initial state #932

jumbosushi opened this issue May 9, 2019 · 0 comments

Comments

@jumbosushi
Copy link
Contributor

jumbosushi commented May 9, 2019

What behavior were you expecting?

When I open ImageManager from new articles page, I expect all filters to start fresh without anything being pre-selected

What actually happened?

Tag filter is initially rendered with onRemove option enabled (aka have X withint the button).

image

Steps to reproduce

  1. Go to /articles/new
  2. Click on Add feature Image
  3. Check filters

What was your environment like?

Google Chrome 74.0.3729.131 on Ubuntu 16.04

Getting started

This component rendered in this line inside ImageManager/index.js.

If you go down the components <TagsFilterInput> renders <ItemSelectinput> which calls getSelected() as defined here which determines what is returned vased on value prop.

When getSelected() is called for TagsFilterInput, the method is returning [[]]. The array of empty array's length is checked here. The goal would be for getSelected() to return [] correctly in the initial render of <TagsFilterInput>

ImageManager currently have this initial state as defined here:

    this.state = {
      author: '',
      tags: [], // Empty array
      q: '',
      limit: DEFAULT_QUERY.limit,
    }

On initial render this.state.tags is passed as value prop of <TagsFilterInput> that is causing this bug.

This issue can be fixed if we update the initial state to be

    this.state = {
      author: '',
      tags: '',    // Empty string
      q: '',
      limit: DEFAULT_QUERY.limit,
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant