Skip to content
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

Fix focus state regression of icons in EuiFormControlLayout. #898

Merged

Conversation

cjcenizal
Copy link
Contributor

@cjcenizal cjcenizal commented Jun 4, 2018

Fixes #893

Thanks for catching this @cchaos!

I tested the following scenarios:

  • Clicking the icon in a EuiSelect now opens the select and gives it focus
  • Clicking the icon in a EuiFieldPassword gives focus to the input
  • Clicking both the clear and caret icons in EuiComboBox still has the original desired behavior of clearing/toggling the EuiComboBox

I also added a note to the CHANGELOG under 0.0.50 noting this regression.

@cjcenizal cjcenizal requested a review from cchaos June 4, 2018 13:51
@cjcenizal cjcenizal force-pushed the bug/form-control-layout-icon-focus branch 2 times, most recently from 473dc12 to 51a8acb Compare June 4, 2018 13:54
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.

Tested in Chrome and IE, seems to be working.

May want to consider adding focusable="false" on the actual EuiIcon components or else you'll get tabbing like so in IE:

@cjcenizal
Copy link
Contributor Author

@cchaos Ready for your 👀 again!

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.

I was able to follow this much better. I just had some comments/concerns mainly about classes.

...rest
}) => {
const classes = classNames(
'euiFormControlLayoutIcons__customIcon',
Copy link
Contributor

Choose a reason for hiding this comment

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

I would think this className should be euiFormControlLayoutCustomIcon to keep with our conventions.

return (
<EuiIcon
aria-hidden="true"
className={classes}
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm, my worry here is that the classes are added directly to the SVG here, but are added to the button if there's a click. It seems we could have misleading/incorrect styles because they're completely different elements with the same classes. Can we maybe just change the outer element to be span or button?

EuiFormControlLayoutCustomIcon.propTypes = {
className: PropTypes.string,
onClick: PropTypes.func,
type: PropTypes.string,
Copy link
Contributor

Choose a reason for hiding this comment

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

iconType vs type ?

onClick,
...rest
}) => {
const classes = classNames('euiFormControlLayoutIcons__clearButton', className);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would think this className should be euiFormControlLayoutClearButton to keep with our conventions.

{...rest}
>
<EuiIcon
className="euiFormControlLayoutIcons__clearButtonIcon"
Copy link
Contributor

Choose a reason for hiding this comment

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

This one would need to change too.

right: $euiFormControlPadding;
}

.euiFormControlLayoutIcons__clearButton {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would split these into their own files as we do other components.


return (
<EuiFormControlLayoutClearButton
aria-label="Clear selections"
Copy link
Contributor

Choose a reason for hiding this comment

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

Label is too specific here, maybe just "Clear" or "Clear input". "Selections" (plural) won't make sense if we use this for single selection elements.

ref: iconRef,
side, // eslint-disable-line no-unused-vars
...iconRest
} = iconProps
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing ;


const {
ref: iconRef,
side, // eslint-disable-line no-unused-vars
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 these two is where I get confused, but I think it's just my lack of knowledge. But are you creating these or supplying these? And if you're creating the iconRef, how does one access it?

width: $euiSize;
@include size($euiSize);

.euiIcon {
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that it's broken down further, I think we can go ahead and give the EuiIcon a custom class for this.

@cchaos cchaos mentioned this pull request Jun 4, 2018
2 tasks
@cjcenizal
Copy link
Contributor Author

Thanks for the review @cchaos. I've addressed your feedback, could you take another look?

@cjcenizal cjcenizal force-pushed the bug/form-control-layout-icon-focus branch from 6d6e4f8 to d3a21c4 Compare June 4, 2018 22:30
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.

LG, tested in IE too. Just one class omission.

{...rest}
>
<EuiIcon
aria-hidden="true"
Copy link
Contributor

Choose a reason for hiding this comment

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

You'd want the same className here as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe even just create a variable for the EuiIcon node

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like it adjusts the position of the icon specifically when it's inside a button, so I don't think it's needed here. Am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yeah... I guess I was thinking long-term in case we or a consumer needed to target that icon specifically, it would be nice to have a class. Meaning, they would actually be the same class .euiFormControlLayoutCustomIcon__icon that would only have specific styles (for now) within .euiFormControlLayoutCustomIcon--clickable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I see. I think I'll punt on this for now since I don't think we have a compelling need for it yet, and it will be simple to add once we do.

@cjcenizal cjcenizal force-pushed the bug/form-control-layout-icon-focus branch from d3a21c4 to 998e419 Compare June 5, 2018 00:07
@cjcenizal cjcenizal merged commit b78e76d into elastic:master Jun 5, 2018
@cjcenizal cjcenizal deleted the bug/form-control-layout-icon-focus branch June 5, 2018 04:37
cchaos pushed a commit to cchaos/eui that referenced this pull request Jun 5, 2018
…lastic#898)"

This reverts commit b78e76d.

# Conflicts:
#	CHANGELOG.md
#	src/components/form/file_picker/_file_picker.scss
#	src/components/form/form_control_layout/_mixins.scss
cchaos pushed a commit to cchaos/eui that referenced this pull request Jun 5, 2018
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.

2 participants