Skip to content

Commit 1aec98a

Browse files
authored
Merge pull request #276 from opf/bug/63443-collapsed-preview-not-working
[63443] Collapsed preview not working
2 parents 5c871a0 + 7ff2d03 commit 1aec98a

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

.changeset/petite-ties-repair.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@openproject/primer-view-components': patch
3+
---
4+
5+
Stabilise initally collapsed state for CollapsibleSection and CollapsibleHeader

app/components/primer/open_project/border_box/collapsible_header.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<% if count? %>
66
<%= count %>
77
<% end %>
8-
<%= render(Primer::Beta::Octicon.new(icon: "chevron-up", data: { target: "collapsible-header.arrowUp" })) %>
9-
<%= render(Primer::Beta::Octicon.new(icon: "chevron-down", hidden: true, data: { target: "collapsible-header.arrowDown" })) %>
8+
<%= render(Primer::Beta::Octicon.new(icon: "chevron-up", hidden: @collapsed, data: { target: "collapsible-header.arrowUp" })) %>
9+
<%= render(Primer::Beta::Octicon.new(icon: "chevron-down", hidden: !@collapsed, data: { target: "collapsible-header.arrowDown" })) %>
1010
<% end %>
1111
<%= flex.with_row do %>
1212
<% if description? %>

app/components/primer/open_project/border_box/collapsible_header.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class CollapsibleHeader < Primer::Component
3939
}
4040
}
4141
)
42+
system_arguments[:hidden] = @collapsed
4243

4344
Primer::Beta::Text.new(**system_arguments, &block)
4445
}

app/components/primer/open_project/collapsible.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export abstract class CollapsibleElement extends HTMLElement {
2424

2525
hideAll() {
2626
// For whatever reason, setting `hidden` directly does not work on the SVGs
27-
this.arrowDown.removeAttribute('hidden')
28-
this.arrowUp.setAttribute('hidden', '')
27+
this.arrowDown?.removeAttribute('hidden')
28+
this.arrowUp?.setAttribute('hidden', '')
2929

3030
for (const el of this.collapsibleElements) {
3131
el.hidden = true
@@ -35,8 +35,8 @@ export abstract class CollapsibleElement extends HTMLElement {
3535
}
3636

3737
expandAll() {
38-
this.arrowUp.removeAttribute('hidden')
39-
this.arrowDown.setAttribute('hidden', '')
38+
this.arrowUp?.removeAttribute('hidden')
39+
this.arrowDown?.setAttribute('hidden', '')
4040

4141
for (const el of this.collapsibleElements) {
4242
el.hidden = false

app/components/primer/open_project/collapsible_section.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
<%= caption %>
1111
<% end %>
1212
<%= header.with_column do %>
13-
<%= render(Primer::Beta::Octicon.new(icon: "chevron-up", data: { target: "collapsible-section.arrowUp" })) %>
14-
<%= render(Primer::Beta::Octicon.new(icon: "chevron-down", hidden: true, data: { target: "collapsible-section.arrowDown" })) %>
13+
<%= render(Primer::Beta::Octicon.new(icon: "chevron-up", hidden: @collapsed, data: { target: "collapsible-section.arrowUp" })) %>
14+
<%= render(Primer::Beta::Octicon.new(icon: "chevron-down", hidden: !@collapsed, data: { target: "collapsible-section.arrowDown" })) %>
1515
<% end %>
1616
<%= header.with_column(flex: 1, text_align: :right) do %>
1717
<%= additional_information %>
1818
<% end %>
1919
<% end %>
2020
<% end %>
21-
<%= flex.with_row(mt: 3, data: { targets: "collapsible-section.collapsibleElements" }) do %>
21+
<%= flex.with_row(hidden: @collapsed, mt: 3, data: { targets: "collapsible-section.collapsibleElements" }) do %>
2222
<%= collapsible_content %>
2323
<% end %>
2424
<% end %>

0 commit comments

Comments
 (0)