Skip to content

Conversation

lbogdan
Copy link
Contributor

@lbogdan lbogdan commented Nov 26, 2017

Adds clearable prop to el-input. When set to true, if the input is not empty and it's focused or hovered, it shows a clear icon, which, when clicked, clears the input.

clearable input

Resolves #8469.

  • Make sure you follow Element's contributing guide (中文 | English).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer relative issues for you PR.

</script>
```
:::

Copy link
Contributor

Choose a reason for hiding this comment

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

Please also add clearable in the Input Attribute table.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any order preference? Should I add it to the end of the attribute list?

Copy link
Contributor Author

@lbogdan lbogdan Nov 26, 2017

Choose a reason for hiding this comment

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

Actually, I'm thinking it would be nice to have attribute / slot / event lists ordered alphabetically (at least for en-US). Would you support a PR for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the order of items is insignificant now, you can append to the list.

Alphabetical order may not be a good idea. I think it's better to group items by their features.
For example: prefix-icon, suffix-icon should stay together.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. I appended it to the list.

clear() {
this.$emit('input', '');
this.setCurrentValue('');
this.focus();
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, everything looks good to me, except that after clearing the input, the change event should trigger. Here we should add

this.$emit('change', '');

<el-input
placeholder="Please input"
v-model="input10"
:clearable="true">
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer clearable shorthand here.

@Leopoldthecoder Leopoldthecoder merged commit 6e8f10a into ElemeFE:dev Nov 27, 2017
@lbogdan
Copy link
Contributor Author

lbogdan commented Nov 29, 2017

@Leopoldthecoder Hey, I see this was released in the new version and it's live on element.eleme.io, thanks! Just wanted to let you know someone should also add it to the zh-CN examples.

@lbogdan lbogdan deleted the feature/input-clearable branch November 29, 2017 12:07
@Leopoldthecoder
Copy link
Contributor

@lbogdan Sorry I forgot about that. Will add it soon.

@wacky6 wacky6 mentioned this pull request Aug 1, 2018
3 tasks
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.

3 participants