Allow setting attributes on editable inputs#1464
Merged
AllenFang merged 3 commits intoAllenFang:v4.0.0-devfrom Jul 16, 2017
Merged
Allow setting attributes on editable inputs#1464AllenFang merged 3 commits intoAllenFang:v4.0.0-devfrom
AllenFang merged 3 commits intoAllenFang:v4.0.0-devfrom
Conversation
AllenFang
requested changes
Jul 10, 2017
src/TableEditColumn.js
Outdated
| let { className } = this.state; | ||
| // put placeholder if exist | ||
| editable.placeholder && (attr.placeholder = editable.placeholder); | ||
| editable.attrs && (attr = {...editable.attrs, ...attr}); |
Owner
There was a problem hiding this comment.
I think following will be simple, keep const and dont assign attr again:
const attr = {
ref: 'inputRef',
onKeyDown: this.handleKeyPress,
onBlur: this.handleBlur,
...editable.attrs
};Please check 👍 thanks
Author
There was a problem hiding this comment.
Yeah that's easier 😁 I spread the user supplied attrs first though so the ref and handlers can't be overwritten.
Author
|
I added the code to allow refs, keydown and blur handlers. Also a warning 'Setting editable.placeholder is deprecated. Use editable.attrs to set input attributes' so you can eventually get rid of separately setting the placeholder attr. |
Owner
|
@jspaine, it sounds good, feel free to patch PR 👍 |
AllenFang
approved these changes
Jul 16, 2017
Owner
|
@jspaine, this was fixed and released on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I think it would be nice if there was an easy way to set attributes for editable inputs without having to create a customEditor. This allows stuff like:
I'd only want it for simple attributes, but I don't like that it just silently ignores anything the user passes for ref, onKeyDown and onBlur and I'm not sure the best way to deal with it. Is it worth the extra code to support these, should ref and on* throw an error...?