Navigation Menu

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

SearchBox dom breaking change in 2.2.0 and later #1952

Closed
shakefu opened this issue Feb 6, 2017 · 7 comments
Closed

SearchBox dom breaking change in 2.2.0 and later #1952

shakefu opened this issue Feb 6, 2017 · 7 comments
Assignees

Comments

@shakefu
Copy link

shakefu commented Feb 6, 2017

Do you want to request a feature or report a bug?

Bug.

Bug: What is the current behavior?

In 2.2.0 and later, the SearchBox widget ignores translation strings, shows large icons, and breaks previous rendering as shown below without a major version change, which means packages are automatically upgraded by NPM according to semantic versioning.

This backwards-incompatible breaking change is undocumented.

screen shot 2017-02-06 at 2 42 13 pm

Bug: What is the expected behavior?

In 2.1.0 the SearchBox widget rendered as below, respecting the translation strings as documented. Some of the CSS here (borders, font size) is our theme, but the base is the SearchBox widget's.

screen shot 2017-02-06 at 2 50 56 pm

Bug: What browsers are impacted? Which versions?

All.

What project are you opening an issue for?

  • react-instantsearch

What is the version you are using? Always use the latest one before opening a bug issue.

We are forced to pin our version to <2.2.0 (meaning: 2.1.0) until we find some way to restore the old rendering behavior. An automatic upgrade according to semantic versioning of the default ^2.1.0 version string put us on 2.2.5. We were able to narrow it down to the 2.2.0 release as introducing this new breaking behavior, most likely PR #1795.

Here is a snippet of our code that generated the previous rendering on 2.1.0 and the broken rendering on 2.2.0 and later:

// components/InstantSearch.js
            <div className="InstantSearch">
                <InstantSearch
                  appId={app_id}
                  apiKey={key}
                  indexName={index}
                  searchState={this.state.searchState}
                  onSearchStateChange={this._onSearchStateChange}
                  searchParameters={{hitsPerPage: 50}}>
                  <SearchBox
                      autoFocus={true}
                      translations={{
                          submit: "Search",
                          reset: "Reset",
                          placeholder: "Search for users ...",
                      }} />
                  <Stats />
                  <Hits hitComponent={UserSummary} />
                </InstantSearch>
            </div>
/* components/InstantSearch.css */
.ais-SearchBox__input {
    border: 2px solid grey;
    border-radius: 5px;
    font-size: 24px;
    padding-top: 8px;
    padding-bottom: 8px;
    padding-left: 16px;
    padding-right: 16px;
    width: 350px;
}

/* Hide the blue focus outline */
.ais-SearchBox__input:focus {
    outline: 0;
}

.ais-SearchBox__reset {
    background-color: white;
    border-radius: 5px;
    border: 2px solid lightgrey;
    color: grey;
    font-size: 24px;
    height: 48px;
    margin: 12px;
    padding-bottom: 8px;
    padding-left: 16px;
    padding-right: 16px;
    padding-top: 8px;
}

.ais-SearchBox__reset:focus, .ais-SearchBox__reset:active {
    outline: 0;
    background-color: #fdd;
}
@vinhlh
Copy link

vinhlh commented Feb 6, 2017

and any migration guide to v3 too 💃

@vvo
Copy link
Contributor

vvo commented Feb 7, 2017

Thanks for the detailed explanation we will try that, it was definitely not done on purpose.

(And I will write a v3 migration guide too)

@mthuret
Copy link
Contributor

mthuret commented Feb 7, 2017

Hi @shakefu, we're sorry for that unwanted breaking change.

With this PR #1954 you will be able to get back the translation of Submit/Reset.
After that you'll need to do some modifications of your stylesheet:

  • hide the submit button
  • hide the reset svg icon
  • change the margin of ais-SearchBox__reset to 9px for example

Will this work for you?

@shakefu
Copy link
Author

shakefu commented Feb 7, 2017

@mthuret Yeap. I'll keep an eye on that PR for when it's merged and close this ticket when I get our code updated.

@vvo
Copy link
Contributor

vvo commented Feb 8, 2017

Migration guide to V3: https://github.com/algolia/instantsearch.js/blob/v2/CHANGELOG.md#migration-guide

@vvo vvo changed the title Undocumented breaking changes in 2.2.0 and later SearchBox dom breaking change in 2.2.0 and later Feb 8, 2017
@vvo vvo closed this as completed in #1991 Feb 28, 2017
@vvo vvo reopened this Mar 1, 2017
@vvo
Copy link
Contributor

vvo commented Mar 1, 2017

@shakefu The current SearchBox state is that we are now using icons by default for search and reset buttons. So there's no more "translations", if you want to have a reset text button in latest version you can do this: https://jsfiddle.net/6p0ta8op/1/

We might want to revisit the SearchBox component if we have another good complete proposal allowing both text and icons in an easy way where styling is also easily.

@vvo vvo closed this as completed Mar 1, 2017
@shakefu
Copy link
Author

shakefu commented Mar 8, 2017

@vvo Thanks! We got ours working, will update to the 3.x line in a sprint or two.

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

4 participants