Skip to content

Added isClearable prop to EuiFieldSearch#2723

Merged
andreadelrio merged 7 commits intoelastic:masterfrom
andreadelrio:clearable-search-field
Jan 6, 2020
Merged

Added isClearable prop to EuiFieldSearch#2723
andreadelrio merged 7 commits intoelastic:masterfrom
andreadelrio:clearable-search-field

Conversation

@andreadelrio
Copy link
Copy Markdown
Contributor

Summary

Adds isClearable prop to EuiFieldSearch. Chrome and IE add a clear button (x) by default which I've hidden using CSS to avoid inconsistent behaviour when isClearable is set to false.

Fixes #1769

isclearable

  • Default clear button in Chrome (now hidden with CSS)

image

  • Default clear button in IE11 (now hidden with CSS)

image

  • EuiFieldSearch with isClearable set to true

image

Checklist

- [ ] Check against all themes for compatability in both light and dark modes

  • Checked in mobile
  • Checked in IE11 and Firefox
  • Props have proper autodocs
  • Added documentation examples
  • Added or updated jest tests
    - [ ] Checked for breaking changes and labeled appropriately
    - [ ] Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

Copy link
Copy Markdown
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks great and functionally works. You might want to consider the existence of this button in disabled and readOnly states. I would assume that if the input were in these states (user can't alter the contents) that they should also not be able to clear the contents.

Screen Shot 2020-01-02 at 11 27 38 AM

Screen Shot 2020-01-02 at 11 27 10 AM

I am also wondering if the default should be true instead of false. My consideration is that this being a search style of input, it usually means users may type in it several different times and it doesn't actually "save" the content. Removing (some) browser defaults of this clear button may be considered a regression.

@andreadelrio
Copy link
Copy Markdown
Contributor Author

Code looks great and functionally works. You might want to consider the existence of this button in disabled and readOnly states. I would assume that if the input were in these states (user can't alter the contents) that they should also not be able to clear the contents.

Screen Shot 2020-01-02 at 11 27 38 AM Screen Shot 2020-01-02 at 11 27 10 AM

I am also wondering if the default should be true instead of false. My consideration is that this being a search style of input, it usually means users may type in it several different times and it doesn't actually "save" the content. Removing (some) browser defaults of this clear button may be considered a regression.

@cchaos thanks for catching that! I disabled isClearable for disabled and readOnly state. I agree that defaulting to clearable makes more sense and is inline with what two major browsers do. I've changed the default.

Copy link
Copy Markdown
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM

Copy link
Copy Markdown
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

@andreadelrio andreadelrio merged commit 3320ddd into elastic:master Jan 6, 2020
}

onClear = () => {
this.props.onChange('');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change does not respect the contract of the onChange handler that expects a React.ChangeEvent

Screen Shot 2020-01-15 at 12 50 05

It caused a regression bug on our side (elastic/kibana#54810), we can quickly fix it but it might have caused a regression on other consumers so it would be better to change it here. @andreadelrio

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pulled this out into a stand-alone issue #2763

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a "clearable" option to EuiFieldSearch to support deleting the contents

4 participants