Skip to content

Conversation

@superpower1
Copy link
Contributor

@superpower1 superpower1 commented Sep 9, 2020

Description

  1. Refactor File Picker to functional component
  2. Add onClick prop for click event on file name
  3. Add onChange prop for change event on file name
  4. Add value prop to make the file name controllable
  5. Change the class name to aui--filepicker-component (Breaking Change)
  6. Add dts prop to Rich Text Editor component (Requested by E2E)

Does this PR introduce a breaking change?

  • Yes
  • No

Manual testing step?

Screenshots (if appropriate):

value={value || fileName}
title={value || fileName}
onClick={clickFile}
/>
Copy link
Contributor

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.

Copy link
Contributor

@lightbringer1991 lightbringer1991 Sep 9, 2020

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.

Copy link
Contributor Author

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

Copy link
Contributor

@devharris7 devharris7 left a comment

Choose a reason for hiding this comment

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

Screen Shot 2020-09-09 at 4 20 19 pm
the borders of input and button are not aligned, is it what we want? lol

Copy link
Contributor

@devharris7 devharris7 left a 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?

Copy link
Contributor

@devharris7 devharris7 left a comment

Choose a reason for hiding this comment

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

LGTM

vinteo
vinteo previously approved these changes Sep 9, 2020
@superpower1
Copy link
Contributor Author

Screen Shot 2020-09-09 at 4 20 19 pm
the borders of input and button are not aligned, is it what we want? lol

Fixed.

/**
* data-test-selector of the rich text editor
*/
dts: PropTypes.string,
Copy link
Contributor Author

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.

/**
* function called when the file name changes
*/
onChange: PropTypes.func,
Copy link
Member

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

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 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);
Copy link
Contributor

@lteacher lteacher Sep 10, 2020

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.

Copy link
Contributor

@lightbringer1991 lightbringer1991 left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +48 to +54
if (_.isFunction(onChange)) {
onChange('');
}
setFileName('');

if (_.isFunction(onRemove)) {
onRemove();
Copy link
Contributor

@knilink knilink Sep 10, 2020

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('')

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.

8 participants