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

Bug: Refactoring host element inconsistencies #2059

Closed
15 tasks done
driskull opened this issue Apr 26, 2021 · 20 comments
Closed
15 tasks done

Bug: Refactoring host element inconsistencies #2059

driskull opened this issue Apr 26, 2021 · 20 comments
Assignees
Labels
4 - verified Issues that have been released and confirmed resolved. architecture Issues tied to the core infrastructure of calcite-components. bug Bug reports for broken functionality. Issues should include a reproduction of the bug. convention Issues relating to conventions and best practices. discussion Issues relating to a conversation where feedback is optional.

Comments

@driskull
Copy link
Member

driskull commented Apr 26, 2021

Actual Behavior

Some of the components are setting attributes on the host element and they maybe shouldn't be. Lets discuss what to do in these scenarios.

Expected Behavior

Host element should only have needed props and attributes applied to it. Things like aria roles, tabIndex, id and event listeners.

Reproduction Steps or Sample

  1. accordion-item: <Host aria-expanded={this.active.toString()} icon-position={this.iconPosition} tabindex="0"> Why iconPosition? Should it be a prop? iconPosition is a private variable but gets set on the host element.
  2. alert: <Host active={active} aria-hidden={hidden.toString()} aria-label={this.label} calcite-hydrated-hidden={hidden} queued={this.queued} role={role}> Why queued and active?
  3. color-picker-swatch: <Host aria-label={hex} title={hex}> Why title? Should it be internal?
  4. combobox-item: <Host aria-hidden disabled={this.disabled} scale={scale} tabIndex={-1}> Why disabled? Scale as well? These are already props.
  5. combobox-item-group: <Host scale={scale}> Why scale here?
  6. dropdown-group: <Host role="menu" scale={scale} title={this.groupTitle}> Why title & scale?
  7. dropdown-item: <Host aria-checked={itemAria} dir={dir} isLink={this.href} role={itemRole} scale={scale} selection-mode={this.selectionMode} tabindex="0"> Why isLink, scale, selectionMode?
  8. input-message: <Host calcite-hydrated-hidden={hidden} theme={this.theme}>Why theme?
  9. modal: <Host aria-modal="true" is-active={this.isActive} role="dialog"> Why is-active?
  10. notice: <Host active={this.active} dir={dir}> Why active?
  11. radio-button: <Host labeled={!!this.el.textContent}> Why labeled? what is that for?
  12. radio-group-item: <Host appearance={appearance} aria-checked={checked.toString()} layout={layout} role="radio" scale={scale}> Why appearnace, layout, scale?
  13. slider: <Host id={id} is-range={this.isRange}> Why isRange?
  14. tab-title: <Host aria-controls={this.controls} aria-expanded={this.active.toString()}hasText={this.hasText} id={id} role="tab" tabindex={this.disabled ? "-1" : "0"}> Why hasText?
  15. value-list-item: <Host data-id={this.guid}> Why data-id?

Relevant Info

@driskull driskull added bug Bug reports for broken functionality. Issues should include a reproduction of the bug. discussion Issues relating to a conversation where feedback is optional. convention Issues relating to conventions and best practices. 1 - assigned Issues that are assigned to a sprint and a team member. architecture Issues tied to the core infrastructure of calcite-components. labels Apr 26, 2021
@jcfranco
Copy link
Member

Agreed. We should avoid tacking on to the host anything that can be encapsulated. Once we solidify the list of exceptions, we could add a rule to enforce it.

How do we want to divvy up the list?

@paulcpederson
Copy link
Member

Agree we should clean these up and be really careful what we put on the host. Most of these are probably going to be for styling purposes as we use selectors like :host([is-active]) for styles. Depending on how far we want to go, many of these could be replaced by styles lower down the element tree attached to a class.

If props really need to be on a host element, we can use reflect: true as that's a cleaner way to get that functionality.

The aria stuff I'd assume is because you want the labels, etc to exist in light dom, but not totally sure.

@driskull
Copy link
Member Author

In most cases, we don't even need to import and return the host if we aren't' setting anything on it. So best bet would be to just not import and use the Host element.

It would definitely help if we had a rule where when host is used we could only set aria prefixed attributes as well as tabIndex.

@driskull
Copy link
Member Author

driskull commented Apr 27, 2021

How do we want to divvy up the list?

@jcfranco : 1-5
@paulcpederson : 6-10
@driskull : 11-15

Sound good?

@paulcpederson
Copy link
Member

Is this part of the current 🏃🏻 ?

@driskull
Copy link
Member Author

Good question. Do you think it should be @jcfranco @paulcpederson @julio8a?

@julio8a
Copy link

julio8a commented Apr 27, 2021

If this is something you guys feel comfortable with completed by the end of the sprint (5/7), Yes.
https://github.com/Esri/calcite-components/projects/8

@bstifle
Copy link

bstifle commented Apr 27, 2021

thinking Paul Bryan should handle 1-15

@julio8a
Copy link

julio8a commented Apr 27, 2021

@driskull @jcfranco @paulcpederson

Should I add this to this sprint?

driskull added a commit that referenced this issue Apr 27, 2021
…ement. #2059 (#2067)

* fix(value-list-item): Remove undocumented properties from the Host element. #2059

* cleanup
driskull added a commit that referenced this issue Apr 28, 2021
…st element. #2059 (#2063)

* fix(radio-button): Remove undocumented property/attribute from the Host element. #2059

* cleanup
@driskull
Copy link
Member Author

Should I add this to this sprint?

I got 5 of them done but I'm not sure if the rest could be done for this sprint. Maybe safer for next sprint?

@driskull
Copy link
Member Author

driskull commented May 4, 2021

Cool. i'll steal them back.

jcfranco added a commit that referenced this issue May 7, 2021
…combobox-item): avoid setting internal attributes on host element (#2085)

#2059
@jcfranco
Copy link
Member

jcfranco commented May 7, 2021

1 – 5 installed!

@jcfranco jcfranco removed their assignment May 7, 2021
driskull added a commit that referenced this issue May 10, 2021
… (#2105)

* fix(modal): Remove undocumented properties from the Host element. #2059

* fix test
@driskull
Copy link
Member Author

The rest of mine are installed.

We just need #2114 installed.

@julio8a julio8a added this to the Sprint 5/10 – 5/21 milestone May 12, 2021
@caripizza
Copy link
Contributor

#2114 was just merged. How should we verify this one @driskull ?

@caripizza caripizza added 3 - installed Issues that have been merged to master branch and are ready for final confirmation. and removed 1 - assigned Issues that are assigned to a sprint and a team member. labels May 17, 2021
@jcfranco
Copy link
Member

I've got a PR coming that will use custom a ESLint rule to catch cases where banned host attributes/props are used. We can verify with that. cc @julio8a

@caripizza caripizza added 4 - verified Issues that have been released and confirmed resolved. and removed 3 - installed Issues that have been merged to master branch and are ready for final confirmation. labels May 21, 2021
@caripizza
Copy link
Contributor

caripizza commented May 21, 2021

Verified on my local master branch by running npm run lint:ts locally. The only error was related to setupTests:

[1] /Users/car11447/Dev/calcite-components/src/tests/setupTests.ts
[1]   9:17  error  Expect must be inside of a test block  jest/no-standalone-expect

x  178 problems (1 error, 177 warnings)

Marking this one verified and closing per Sprint planning conversation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - verified Issues that have been released and confirmed resolved. architecture Issues tied to the core infrastructure of calcite-components. bug Bug reports for broken functionality. Issues should include a reproduction of the bug. convention Issues relating to conventions and best practices. discussion Issues relating to a conversation where feedback is optional.
Projects
None yet
Development

No branches or pull requests

7 participants