-
Notifications
You must be signed in to change notification settings - Fork 5
refactor: file picker component #1072
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
base: master
Are you sure you want to change the base?
Conversation
| value={value || fileName} | ||
| title={value || fileName} | ||
| onClick={clickFile} | ||
| /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@superpower1 @minhe86 can you put dts in this input as well, thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like data-test-selector={`${dts}-form-control`}, if dts exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will put dts to the wrapper div instead
devharris7
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
devharris7
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add a new example to doc, and when hovering on the file, if we should give an underline to the file name?
devharris7
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
239d615 to
8f1f580
Compare
| /** | ||
| * data-test-selector of the rich text editor | ||
| */ | ||
| dts: PropTypes.string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sneak in a change to add dts to RichTextEditor.
8f1f580 to
944d286
Compare
| /** | ||
| * function called when the file name changes | ||
| */ | ||
| onChange: PropTypes.func, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't exactly recollect the discussion, however, didn't we decide to cut down the handler functions.
do we need onSelect, onClick, onChange, onRemove for this picker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we were planning to retain the onSelect for scenarios where the value is handled by the component
| const file = event.target.files[0]; | ||
| setIsFileSelected(true); | ||
| if (_.isFunction(onChange)) { | ||
| onChange(file.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should probably provide the actual file for the onChange instead of just the name and allow the external component to put the file's name into the value. In those scenarios they would also not need to use onSelect since they have the power to do whatever and they also have the file itself to manage rather than it being hidden in the component.
lightbringer1991
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| if (_.isFunction(onChange)) { | ||
| onChange(''); | ||
| } | ||
| setFileName(''); | ||
|
|
||
| if (_.isFunction(onRemove)) { | ||
| onRemove(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite sure about this. Triggering multiple handlers here seems to be a little bit confusing to me.
IMO should only keep either onChange('') or onRemove(), otherwise there will be multiple ways of doing the same thing.
the usage should be either
// handle remove with onChange('')
handleChange = (value) => {
if(value==='') {/* handle remove */}
}or
// setValue('') with onRemove()
handleRemove = () => setValue('')
Description
onClickprop for click event on file nameonChangeprop for change event on file namevalueprop to make the file name controllableaui--filepicker-component(Breaking Change)dtsprop to Rich Text Editor component (Requested by E2E)Does this PR introduce a breaking change?
Manual testing step?
Screenshots (if appropriate):