Skip to content

Conversation

@ffknob
Copy link
Contributor

@ffknob ffknob commented Jan 7, 2020

Summary

Closes #2737

Added possibility to set the input properties for the min and max inputs of EuiDualRange.

Checklist

  • Check against all themes for compatibility 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

@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@myasonik
Copy link
Contributor

myasonik commented Jan 7, 2020

Not sure if this is the best API for this... Maybe we can do something like having a prop that takes an object and that whole object will be merged into the input?

I'm looking towards something more flexible because it's likely we'll want to be able to add other aria attributes to these inputs (such as aria-labelledby and aria-describedby) and it also unlocks some future capabilities like disabling only the min or max input while allowing the other to be used.

@ffknob
Copy link
Contributor Author

ffknob commented Jan 7, 2020

ng towards something more flexible because it's likely we'll want to be able to add other aria attributes to these inputs

Do you mean instead of having an ariaLabels array with only that property, there should be an aria property, which would hold two objects, one for the min input and the other one for the max, each of which would allow any of the aria properties to be set... something like this?

EuiDualRange.propTypes = {
  ...
  aria: PropTypes.arrayOf(
    PropTypes.shape({
      'aria-label': PropTypes.string,
      'aria-labelledby': PropTypes.string,
      'aria-describedby': PropTypes.string,
    })
  ),
};

Then:

    const minInputAria = aria && aria[0] ? aria[0] : null;
    const maxInputAria = aria && aria[1] ? aria[1] : null;

And finally:

      <EuiRangeInput
       ...
        {...minInputAria}
      />

      <EuiRangeInput
       ...
        {...maxInputAria}
      />

(I'm not sure if this works or not, I'm just thinking out loud for now...)

@myasonik
Copy link
Contributor

myasonik commented Jan 7, 2020

That's the direction I'm thinking but I would go even broader and not specify a shape. Something like:

EuiDualRange.propTypes = {
  ...
  minInputProps: PropTypes.object,
  maxInputProps: PropTypes.object
};
<EuiRangeInput
  ...
  {...minInputProps}
/>
<EuiRangeInput
  ...
  {...maxInputProps}
/>

This lets implementing devs pass in whatever props they need without EUI having to whitelist individual things.

@cchaos
Copy link
Contributor

cchaos commented Jan 7, 2020

I agree with @myasonik that it should just be a generic ...rest style of object to pass to each input (which once TS'd can extend EuiRangeInput's type). Just be careful though that props like disabled and readOnly don't get overridden by the ...rest style prop.

@ffknob ffknob changed the title EuiDualRange: Adds possibility to set aria-label for inputs EuiDualRange: Add possibility to set input properties for min and max inputs Jan 7, 2020
@cchaos
Copy link
Contributor

cchaos commented Jan 7, 2020

@ffknob Looks like you've got quite a few conflicts. Can you resolve those?

@thompsongl
Copy link
Contributor

Sorry about the conflicts, @ffknob. I had a PR to convert these components to TypeScript that merged this morning; I didn't see your work here. Let me know if you want/need a hand with resolving the changes.

@ffknob
Copy link
Contributor Author

ffknob commented Jan 8, 2020

Sorry about the conflicts, @ffknob. I had a PR to convert these components to TypeScript that merged this morning; I didn't see your work here. Let me know if you want/need a hand with resolving the changes.

No worries @thompsongl
I tried to simply...

  minInputProps?: InputHTMLAttributes<HTMLInputElement>;
  maxInputProps?: InputHTMLAttributes<HTMLInputElement>;

...but it gave me a lot of Typescript type errors with the EuiRangeInput's min,max, step and value properties.

I then solved this by creating the InputProps type... If you have a better suggestion please let me know.

@thompsongl
Copy link
Contributor

@ffknob The interface to be used is EuiRangeInputProps. So import it from './range_input' on L15, and on then on L55-56:

minInputProps?: Partial<EuiRangeInputProps>;
maxInputProps?: Partial<EuiRangeInputProps>;

Just be careful though that props like disabled and readOnly don't get overridden by the ...rest style prop.

To the point made by @cchaos, this would allow consumers to clobber a lot of the props already being set (e.g., disabled). We could indicate in the docs that this prop is intended for use with aria attributes to dissuade from overwriting too much. Maintaining a specific list of props to allow or deny seems unmaintainable.

Copy link
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.

@ffknob Sorry this one is a bit more complicated than it set out because it's not just about adding one prop anymore but extending those of the inputs but ensuring the component still applies the props it needs to. I've passed you a PR here: ffknob#2

…ls/cchaos

Helping with dual range input props
@ffknob
Copy link
Contributor Author

ffknob commented Jan 8, 2020

@cchaos thanks for leaving comments for each change, I always learn a lot with you guys

Copy link
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 once the CL conflict is resolved.

@thompsongl
Copy link
Contributor

jenkins test this

@cchaos cchaos merged commit 38c70e8 into elastic:master Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EuiDualRange inputs are missing aria labels

6 participants