-
Notifications
You must be signed in to change notification settings - Fork 77
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
feat(list-item): deprecate open/close props in favor of expanded/collapsed #11003
Draft
Elijbet
wants to merge
2
commits into
dev
Choose a base branch
from
elijbet/6473-update-open-close-pattern
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+98
−45
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,7 @@ export class ListItem | |
|
||
@state() level: number = null; | ||
|
||
@state() openable = false; | ||
@state() expandable = false; | ||
|
||
@state() parentListEl: List["el"]; | ||
|
||
|
@@ -111,12 +111,26 @@ export class ListItem | |
*/ | ||
@property() bordered = false; | ||
|
||
/** When `true`, a close button is added to the component. */ | ||
/** | ||
* When `true`, a close button is added to the component. | ||
* | ||
* @deprecated Use `collapsible` prop instead. | ||
*/ | ||
@property({ reflect: true }) closable = false; | ||
|
||
/** When `true`, hides the component. */ | ||
/** When `true`, a close button is added to the component. */ | ||
@property({ reflect: true }) collapsible = false; | ||
|
||
/** | ||
* When `true`, hides the component. | ||
* | ||
* @deprecated Use `collapsed` prop instead. | ||
*/ | ||
@property({ reflect: true }) closed = false; | ||
|
||
/** When `true`, hides the component. */ | ||
@property({ reflect: true }) collapsed = false; | ||
|
||
/** A description for the component. Displays below the label text. */ | ||
@property() description: string; | ||
|
||
|
@@ -177,9 +191,16 @@ export class ListItem | |
*/ | ||
@property() moveToItems: MoveTo[] = []; | ||
|
||
/** When `true`, the item is open to show child components. */ | ||
/** | ||
* When `true`, the item is open to show child components. | ||
* | ||
* @deprecated Use `expanded` prop instead. | ||
*/ | ||
@property({ reflect: true }) open = false; | ||
|
||
/** When `true`, the item is expanded to show child components. */ | ||
@property({ reflect: true }) expanded = false; | ||
|
||
/** | ||
* Specifies the size of the component. | ||
* | ||
|
@@ -300,7 +321,7 @@ export class ListItem | |
calciteInternalListItemToggle = createEvent({ cancelable: false }); | ||
|
||
/** Fires when the close button is clicked. */ | ||
calciteListItemClose = createEvent({ cancelable: false }); | ||
calciteListItemCollapsed = createEvent({ cancelable: false }); | ||
|
||
/** Fires when the component is selected. */ | ||
calciteListItemSelect = createEvent({ cancelable: false }); | ||
|
@@ -357,20 +378,32 @@ export class ListItem | |
To account for this semantics change, the checks for (this.hasUpdated || value != defaultValue) was added in this method | ||
Please refactor your code to reduce the need for this check. | ||
Docs: https://qawebgis.esri.com/arcgis-components/?path=/docs/lumina-transition-from-stencil--docs#watching-for-property-changes */ | ||
if (changes.has("expanded")) { | ||
this.open = this.expanded; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is correct. expanded should set expanded, open should set open. I think what needs to happen is that open and expanded each need a custom setter to set the other one when one is set. |
||
} | ||
|
||
if (changes.has("collapsible")) { | ||
this.closable = this.collapsible; | ||
} | ||
|
||
if (changes.has("collapsed")) { | ||
this.closed = this.collapsed; | ||
} | ||
|
||
if (changes.has("active") && (this.hasUpdated || this.active !== false)) { | ||
this.activeHandler(this.active); | ||
} | ||
|
||
if (changes.has("closed") && (this.hasUpdated || this.closed !== false)) { | ||
this.handleClosedChange(); | ||
this.handleCollapsedChange(); | ||
} | ||
|
||
if (changes.has("disabled") && (this.hasUpdated || this.disabled !== false)) { | ||
this.handleDisabledChange(); | ||
} | ||
|
||
if (changes.has("open") && (this.hasUpdated || this.open !== false)) { | ||
this.handleOpenChange(); | ||
this.handleExpandedChange(); | ||
} | ||
|
||
if (changes.has("selected") && (this.hasUpdated || this.selected !== false)) { | ||
|
@@ -382,7 +415,7 @@ export class ListItem | |
} | ||
|
||
if (changes.has("displayMode") && this.hasUpdated) { | ||
this.handleOpenableChange(this.defaultSlotEl.value); | ||
this.handleExpandableChange(this.defaultSlotEl.value); | ||
} | ||
} | ||
|
||
|
@@ -404,15 +437,15 @@ export class ListItem | |
} | ||
} | ||
|
||
private handleClosedChange(): void { | ||
private handleCollapsedChange(): void { | ||
this.emitCalciteInternalListItemChange(); | ||
} | ||
|
||
private handleDisabledChange(): void { | ||
this.emitCalciteInternalListItemChange(); | ||
} | ||
|
||
private handleOpenChange(): void { | ||
private handleExpandedChange(): void { | ||
this.emitCalciteInternalListItemToggle(); | ||
} | ||
|
||
|
@@ -431,7 +464,7 @@ export class ListItem | |
|
||
private handleCalciteInternalListDefaultSlotChanges(event: CustomEvent<void>): void { | ||
event.stopPropagation(); | ||
this.handleOpenableChange(this.defaultSlotEl.value); | ||
this.handleExpandableChange(this.defaultSlotEl.value); | ||
} | ||
|
||
private setSortHandleEl(el: SortHandle["el"]): void { | ||
|
@@ -489,9 +522,9 @@ export class ListItem | |
this.calciteInternalListItemChange.emit(); | ||
} | ||
|
||
private handleCloseClick(): void { | ||
private handleCollapseClick(): void { | ||
this.closed = true; | ||
this.calciteListItemClose.emit(); | ||
this.calciteListItemCollapsed.emit(); | ||
} | ||
|
||
private handleContentSlotChange(event: Event): void { | ||
|
@@ -534,16 +567,16 @@ export class ListItem | |
} | ||
} | ||
|
||
private handleOpenableChange(slotEl: HTMLSlotElement): void { | ||
private handleExpandableChange(slotEl: HTMLSlotElement): void { | ||
if (!slotEl) { | ||
return; | ||
} | ||
|
||
this.openable = this.displayMode === "nested" && hasListItemChildren(slotEl); | ||
this.expandable = this.displayMode === "nested" && hasListItemChildren(slotEl); | ||
} | ||
|
||
private handleDefaultSlotChange(event: Event): void { | ||
this.handleOpenableChange(event.target as HTMLSlotElement); | ||
this.handleExpandableChange(event.target as HTMLSlotElement); | ||
} | ||
|
||
private handleToggleClick(): void { | ||
|
@@ -603,7 +636,7 @@ export class ListItem | |
actionsStartEl: { value: actionsStartEl }, | ||
actionsEndEl: { value: actionsEndEl }, | ||
open, | ||
openable, | ||
expandable, | ||
} = this; | ||
|
||
const cells = this.getGridCells(); | ||
|
@@ -620,7 +653,7 @@ export class ListItem | |
event.preventDefault(); | ||
const nextIndex = currentIndex + 1; | ||
if (currentIndex === -1) { | ||
if (!open && openable) { | ||
if (!open && expandable) { | ||
this.toggle(true); | ||
this.focusCell(null); | ||
} else if (cells[0]) { | ||
|
@@ -634,7 +667,7 @@ export class ListItem | |
const prevIndex = currentIndex - 1; | ||
if (currentIndex === -1) { | ||
this.focusCell(null); | ||
if (open && openable) { | ||
if (open && expandable) { | ||
this.toggle(false); | ||
} else { | ||
this.calciteInternalFocusPreviousItem.emit(); | ||
|
@@ -759,34 +792,34 @@ export class ListItem | |
) : null; | ||
} | ||
|
||
private renderOpen(): JsxNode { | ||
const { el, open, openable, messages, displayMode, scale } = this; | ||
private renderExpanded(): JsxNode { | ||
const { el, open, expandable, messages, displayMode, scale } = this; | ||
|
||
if (displayMode !== "nested") { | ||
return null; | ||
} | ||
|
||
const dir = getElementDir(el); | ||
|
||
const icon = openable | ||
const icon = expandable | ||
? open | ||
? ICONS.open | ||
: dir === "rtl" | ||
? ICONS.closedRTL | ||
: ICONS.closedLTR | ||
? ICONS.collapsedRTL | ||
: ICONS.collapsedLTR | ||
: ICONS.blank; | ||
|
||
const iconScale = getIconScale(scale); | ||
|
||
const tooltip = openable ? (open ? messages.collapse : messages.expand) : undefined; | ||
const tooltip = expandable ? (open ? messages.collapse : messages.expand) : undefined; | ||
|
||
const openClickHandler = openable ? this.handleToggleClick : undefined; | ||
const expandedClickHandler = expandable ? this.handleToggleClick : undefined; | ||
|
||
return ( | ||
<div | ||
class={CSS.openContainer} | ||
key="open-container" | ||
onClick={openClickHandler} | ||
class={CSS.expandedContainer} | ||
key="expanded-container" | ||
onClick={expandedClickHandler} | ||
title={tooltip} | ||
> | ||
<calcite-icon icon={icon} key={icon} scale={iconScale} /> | ||
|
@@ -827,11 +860,11 @@ export class ListItem | |
{closable ? ( | ||
<calcite-action | ||
appearance="transparent" | ||
class={CSS.close} | ||
class={CSS.collapse} | ||
icon={ICONS.close} | ||
key="close-action" | ||
label={messages.close} | ||
onClick={this.handleCloseClick} | ||
onClick={this.handleCollapseClick} | ||
scale={this.scale} | ||
text={messages.close} | ||
/> | ||
|
@@ -881,7 +914,7 @@ export class ListItem | |
<div | ||
class={{ | ||
[CSS.nestedContainer]: true, | ||
[CSS.nestedContainerOpen]: this.openable && this.open, | ||
[CSS.nestedContainerExpanded]: this.expandable && this.open, | ||
}} | ||
> | ||
<slot onSlotChange={this.handleDefaultSlotChange} ref={this.defaultSlotEl} /> | ||
|
@@ -941,7 +974,7 @@ export class ListItem | |
|
||
override render(): JsxNode { | ||
const { | ||
openable, | ||
expandable, | ||
open, | ||
level, | ||
active, | ||
|
@@ -974,7 +1007,7 @@ export class ListItem | |
<InteractiveContainer disabled={disabled}> | ||
<div class={{ [CSS.wrapper]: true, [CSS.wrapperBordered]: wrapperBordered }}> | ||
<div | ||
ariaExpanded={openable ? open : null} | ||
ariaExpanded={expandable ? open : null} | ||
ariaLabel={label} | ||
ariaLevel={level} | ||
ariaSelected={selected} | ||
|
@@ -996,7 +1029,7 @@ export class ListItem | |
> | ||
{this.renderDragHandle()} | ||
{this.renderSelected()} | ||
{this.renderOpen()} | ||
{this.renderExpanded()} | ||
{this.renderActionsStart()} | ||
<div | ||
class={{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be collapsible. It isn't collapsed, it isn't shown at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think closed/closable needs to remain as is.