Skip to content

Commit 9e49c35

Browse files
committed
chore: Update package version to 1.0.180 and improve Accordion component
1 parent fb66941 commit 9e49c35

File tree

4 files changed

+14
-112
lines changed

4 files changed

+14
-112
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@programmer_network/yail",
3-
"version": "1.0.179",
3+
"version": "1.0.180",
44
"description": "Programmer Network's official UI library for React",
55
"author": "Aleksandar Grbic - (https://programmer.network)",
66
"publishConfig": {

src/Components/Accordion/Accordion.stories.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ export const NonInteractive = () => {
110110
sections={sections}
111111
setSections={setSections}
112112
expanded={expandedSections}
113-
hasDraggableSections={true}
114-
hasDraggableSectionItems={true}
115113
setExpanded={(expanded: number[]) => {
116114
setExpandedSections(expanded);
117115
}}

src/Components/Accordion/__snapshots__/Accordion.test.tsx.snap

Lines changed: 0 additions & 99 deletions
This file was deleted.

src/Components/Accordion/index.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,21 @@ const Accordion: FC<IAccordionProps> = ({
103103
role='presentation'
104104
>
105105
<h3
106-
onClick={() => {
106+
onClick={e => {
107+
e.stopPropagation();
108+
e.preventDefault();
107109
setSelectedSectionId(section.id);
108110
}}
109111
className={classNames(
110-
"yl-relative yl-flex yl-cursor-pointer yl-select-none yl-items-center yl-font-semibold yl-capitalize yl-p-4",
112+
"yl-relative yl-flex yl-cursor-default yl-select-none yl-items-center yl-font-semibold yl-capitalize yl-p-4",
111113
sectionTitleClassName,
112114
{
113115
"yl-bg-primary-text-color/5": expanded.includes(section.id),
116+
"yl-cursor-pointer": onSectionItemClick,
114117
"yl-text-primary-text-color":
115-
selectedSectionId !== section.id,
116-
"yl-text-primary": selectedSectionId === section.id
118+
selectedSectionId !== section.id || !onSectionItemClick,
119+
"yl-text-primary":
120+
onSectionItemClick && selectedSectionId === section.id
117121
}
118122
)}
119123
onKeyDown={e =>
@@ -160,6 +164,11 @@ const Accordion: FC<IAccordionProps> = ({
160164
{expanded.includes(section.id) && (
161165
<DraggableList
162166
items={section.items}
167+
onClick={(item: IDraggableListItem) => {
168+
onSectionItemClick?.(item);
169+
onSelected?.(item);
170+
setSelectedItemId(item.id);
171+
}}
163172
onDragged={(items: IDraggableListItem[]) => {
164173
setSections(
165174
[
@@ -185,12 +194,6 @@ const Accordion: FC<IAccordionProps> = ({
185194
}
186195
)
187196
}
188-
onClick={(item: IDraggableListItem) => {
189-
onSectionItemClick?.(item);
190-
onSelected?.(item);
191-
setSelectedItemId(item.id);
192-
setSelectedSectionId(section.id);
193-
}}
194197
/>
195198
)}
196199
</div>

0 commit comments

Comments
 (0)