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

refactor(tabs, tab, tab-nav, tab-title): getElementProp is refactored out in favor of inheritable props set directly on parent #7605

Merged
merged 60 commits into from
Oct 30, 2023

Conversation

Elijbet
Copy link
Contributor

@Elijbet Elijbet commented Aug 25, 2023

Related Issue: #6038

Summary

getElementProp is refactored out across child components as an outdated pattern in favor of inheritable props set directly on the parent. Instead of the tab, tab-title, tab-nav looking up the parent for position and scale, these get set by the tabs parent.

The logic for setting these props thus moves to the parent, getting rid of the getElementProp altogether. The parent component gets a mutationObserver to achieve this and watchers for when it needs to modify the children. Child attribute selectors are subbed with new classes added dynamically to reflect the scale and position, as attributes are no longer reflected to be targeted.

Inherited props addressed:

  • position
  • scale

@github-actions github-actions bot added the refactor Issues tied to code that needs to be significantly reworked. label Aug 25, 2023
@Elijbet Elijbet changed the title refactor(tabs, tab, tab-nav, tab-title): getElementProp is refactored out in favor of inheritable props set directly on parent refactor(tabs, tab, tab-nav, tab-title): getElementProp is refactored out in favor of inheritable props set directly on parent Aug 25, 2023
@github-actions
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity. Please close your PR if it is no longer relevant. Thank you for your contributions.

@github-actions github-actions bot added the Stale Issues or pull requests that have not had recent activity. label Sep 21, 2023
@Elijbet Elijbet added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Oct 26, 2023
Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

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

👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾
👾🕹️🕹️🕹️🕹️👾🕹️👾👾👾👾👾🕹️👾🕹️🕹️🕹️🕹️👾👾🕹️🕹️🕹️👾👾🕹️🕹️👾👾🕹️👾👾👾🕹️👾🕹️🕹️🕹️🕹️👾🕹️👾
👾🕹️👾👾🕹️👾🕹️👾👾👾👾👾🕹️👾🕹️👾👾👾👾🕹️👾👾👾👾🕹️👾👾🕹️👾🕹️🕹️👾🕹️🕹️👾🕹️👾👾👾👾🕹️👾
👾🕹️🕹️🕹️🕹️👾🕹️👾👾🕹️👾👾🕹️👾🕹️🕹️🕹️👾👾👾🕹️🕹️👾👾🕹️👾👾🕹️👾🕹️👾🕹️👾🕹️👾🕹️🕹️🕹️👾👾🕹️👾
👾🕹️👾👾🕹️👾🕹️👾🕹️👾🕹️👾🕹️👾🕹️👾👾👾👾👾👾👾🕹️👾🕹️👾👾🕹️👾🕹️👾👾👾🕹️👾🕹️👾👾👾👾👾👾
👾🕹️👾👾🕹️👾👾🕹️👾👾👾🕹️👾👾🕹️🕹️🕹️🕹️👾🕹️🕹️🕹️👾👾👾🕹️🕹️👾👾🕹️👾👾👾🕹️👾🕹️🕹️🕹️🕹️👾🕹️👾
👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾

@Elijbet Elijbet added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Oct 28, 2023
@Elijbet Elijbet removed the pr ready for visual snapshots Adding this label will run visual snapshot testing. label Oct 29, 2023
@Elijbet Elijbet added the pr ready for visual snapshots Adding this label will run visual snapshot testing. label Oct 29, 2023
@geospatialem geospatialem added the low risk Issues with low risk for consideration in low risk milestones label Oct 30, 2023
@@ -69,7 +69,7 @@ export class Tab {
role="tabpanel"
tabIndex={this.selected ? 0 : -1}
>
<section>
<section class={CSS.content}>
Copy link
Member

Choose a reason for hiding this comment

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

Not for this PR, but it'd be good to replace all selectors using section with the content class.

position="${select("position", ["top", "bottom"], "top")}"
scale="${select("scale", ["s", "m", "l"], "l")}"
>
const TabNavHTMLSimple = html`
Copy link
Member

Choose a reason for hiding this comment

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

Awesome job adding more coverage! ✨🧪🧪🧪✨

@@ -166,7 +166,7 @@ export class Tabs {
}
});

private updateItems = (): void => {
private updateItems(): void {
Copy link
Member

Choose a reason for hiding this comment

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

✨🏆✨

}
);

Array.from(this.el.querySelectorAll("calcite-tab")).forEach((tab: HTMLCalciteTabElement) => {
Copy link
Member

Choose a reason for hiding this comment

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

Queries target all descendants, so this will be an issue when you have nested tabs with different props each. Not sure how common position and scale being different between nested tabs would be, so this could be an edge case.

@Elijbet Elijbet added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Oct 30, 2023
Elijbet added a commit that referenced this pull request Oct 30, 2023
**Related Issue:** N/A

## Summary

Fails on unrelated PR: #7605 

Looks like it's DST-related, as London is used in E2E tests and it had a
DST adjustment on 10/2 per @jcfranco

🫤 🤔 🤨 🧐
@Elijbet Elijbet added skip visual snapshots Pull requests that do not need visual regression testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Oct 30, 2023
@Elijbet Elijbet merged commit e070d7d into main Oct 30, 2023
14 checks passed
@Elijbet Elijbet deleted the elijbet/6038-refactor-getElementProp-tab-title branch October 30, 2023 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low risk Issues with low risk for consideration in low risk milestones refactor Issues tied to code that needs to be significantly reworked. skip visual snapshots Pull requests that do not need visual regression testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants