Skip to content

Commit fe79a5a

Browse files
fix(accordion): remove divider from last accordion item in ionic theme
1 parent 966d6b2 commit fe79a5a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

core/src/components/accordion/accordion.ionic.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
z-index: 3;
2929
}
3030

31+
// Hide the divider for the last accordion item
32+
:host(.accordion-last)::after {
33+
display: none;
34+
}
35+
3136
:host(.accordion-animated) {
3237
transition: all 300ms cubic-bezier(0.25, 0.8, 0.5, 1);
3338
}

core/src/components/accordion/accordion.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export class Accordion implements ComponentInterface {
8787
@State() state: AccordionState = AccordionState.Collapsed;
8888
@State() isNext = false;
8989
@State() isPrevious = false;
90+
@State() isLast = false;
9091
/**
9192
* Tracks whether a user-initiated interaction has occurred.
9293
* Animations are disabled until the first interaction happens.
@@ -431,6 +432,12 @@ export class Accordion implements ComponentInterface {
431432

432433
const shouldExpand = Array.isArray(value) ? value.includes(accordionValue) : value === accordionValue;
433434

435+
/**
436+
* Check if this is the last accordion in the group.
437+
*/
438+
const nextAccordion = this.getNextSibling();
439+
this.isLast = nextAccordion === undefined;
440+
434441
if (shouldExpand) {
435442
this.expandAccordion();
436443
this.isNext = this.isPrevious = false;
@@ -444,7 +451,6 @@ export class Accordion implements ComponentInterface {
444451
* applied. Check to see if the
445452
* next or previous accordion is selected.
446453
*/
447-
const nextAccordion = this.getNextSibling();
448454
const nextAccordionValue = nextAccordion?.value;
449455

450456
if (nextAccordionValue !== undefined) {
@@ -525,6 +531,7 @@ export class Accordion implements ComponentInterface {
525531

526532
'accordion-next': this.isNext,
527533
'accordion-previous': this.isPrevious,
534+
'accordion-last': this.isLast,
528535

529536
'accordion-disabled': disabled,
530537
'accordion-readonly': readonly,

0 commit comments

Comments
 (0)