govuk_publishing_components 24.6.0 → 24.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6831e98d8b1db5f3d0cef2f7a7e7cc5439f4bfed8e1c929aedcf9fc98774a7c
4
- data.tar.gz: 85579af6ac2c4ab5970ef2c55d64e1ef8bbbd8978635a00186514e86a53340aa
3
+ metadata.gz: b8b508d510a7aa8f9311afcb0cbb99c28c02b8128e231fbddea0ceac450bda59
4
+ data.tar.gz: 2fc60e40d72fdb1fd6dfb635782a982e5105c4df41d8a40e71ff2985b669eaed
5
5
  SHA512:
6
- metadata.gz: 92158ef074a519f279584aadd38bab2d44fac46b04ee7fffe62bfb8d1d3a15f41825e12d666a692c200dee5baf827bc82190642b48443918f90cd6a62e57c277
7
- data.tar.gz: 4937053696a56e4b30b89b9190a3ab99f6c5b080774acc89395eecf6549c233a219ac857fef5d6aa0e8e93671097178f66cec5091660a13e29677ee1d030e13a
6
+ metadata.gz: 2a43864b134f08d16145c1f39ade8bb21de88cfbe9e2f9bb92af0780e2cce92da0381495a61a9d95e40f80d66a6a739ba75ad00b18c975df2f2ccd8232749d2c
7
+ data.tar.gz: a379f9f22980a8dbddd8e0af9752055ad8f93fd45a144a1a339d153c5670d26e6bbbda904acd13b91c56e0e797a8e9ed5b82cd190dd9926810d2c41d12ba4691
@@ -293,8 +293,10 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
293
293
 
294
294
  // Navigate to and open accordions with anchored content on page load if a hash is present
295
295
  GemAccordion.prototype.openByAnchorOnLoad = function () {
296
- if (window.location.hash && this.$module.querySelector(window.location.hash)) {
297
- this.openForAnchor(window.location.hash)
296
+ var splitHash = window.location.hash.split('#')[1]
297
+
298
+ if (window.location.hash && document.getElementById(splitHash)) {
299
+ this.openForAnchor(splitHash)
298
300
  }
299
301
  }
300
302
 
@@ -305,20 +307,20 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
305
307
 
306
308
  links.forEach(function (link) {
307
309
  if (link.pathname === window.location.pathname) {
308
- link.addEventListener('click', this.openForAnchor.bind(this, link.hash))
310
+ link.addEventListener('click', this.openForAnchor.bind(this, link.hash.split('#')[1]))
309
311
  }
310
312
  }.bind(this))
311
313
  }
312
314
 
313
315
  // Find the parent accordion section for the given id and open it
314
316
  GemAccordion.prototype.openForAnchor = function (hash) {
315
- var target = document.querySelector(hash)
317
+ var target = document.getElementById(hash)
316
318
  var section = this.getContainingSection(target)
317
319
 
318
320
  this.setExpanded(true, section)
319
321
  }
320
322
 
321
- // Loop through the given ids ancestors until the parent section class is found
323
+ // Loop through the given id's ancestors until the parent section class is found
322
324
  GemAccordion.prototype.getContainingSection = function (target) {
323
325
  while (!target.classList.contains(this.sectionClass)) {
324
326
  target = target.parentElement
@@ -81,7 +81,7 @@
81
81
  <%= link_to item[:edit].fetch(:href),
82
82
  class: "govuk-link",
83
83
  data: item[:edit].fetch(:data_attributes, {}) do %>
84
- <%= edit_link_text %><%= tag.span " #{item[:field]}", class: "govuk-visually-hidden" unless edit[:link_text_no_enhance] -%>
84
+ <%= edit_link_text %><%= tag.span " #{item[:field]}", class: "govuk-visually-hidden" unless item[:edit][:link_text_no_enhance] -%>
85
85
  <% end %>
86
86
  <% end %>
87
87
  <% end %>
@@ -94,7 +94,7 @@
94
94
  <%= link_to item[:delete].fetch(:href),
95
95
  class: "govuk-link gem-link--destructive",
96
96
  data: item[:delete].fetch(:data_attributes, {}) do %>
97
- <%= delete_link_text %><%= tag.span " #{item[:field]}", class: "govuk-visually-hidden" unless delete[:link_text_no_enhance] -%>
97
+ <%= delete_link_text %><%= tag.span " #{item[:field]}", class: "govuk-visually-hidden" unless item[:delete][:link_text_no_enhance] -%>
98
98
  <% end %>
99
99
  <% end %>
100
100
  <% end %>
@@ -73,7 +73,24 @@ examples:
73
73
 
74
74
  To override this behaviour, use `link_text_no_enhance` on the link in question, as shown. This will remove the visually hidden text, allowing you to add your own. The component will render a `span` element with a class of `govuk-visually-hidden` included in a passed [capture block](https://apidock.com/rails/ActionView/Helpers/CaptureHelper/capture) as the `link_text` parameter.
75
75
  data:
76
- <<: *default-example-data
76
+ title: "Title, summary and body"
77
+ items:
78
+ - field: "Title"
79
+ value: "Rural conservation techniques"
80
+ edit:
81
+ href: "edit-title"
82
+ text: "Edit"
83
+ data_attributes:
84
+ gtm: "edit-title"
85
+ - field: "Body"
86
+ value: "Following the land use committee change to overreaching rural byelaws in 2009, further policies were adopted."
87
+ edit:
88
+ href: "edit-body"
89
+ link_text: "Edit"
90
+ delete:
91
+ href: "delete-body"
92
+ link_text: "Remove"
93
+ link_text_no_enhance: true
77
94
  edit:
78
95
  href: "edit-title-summary-body"
79
96
  link_text: Edit this document <span class="govuk-visually-hidden">my hidden text for screenreaders</span>
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "24.6.0".freeze
2
+ VERSION = "24.6.1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 24.6.0
4
+ version: 24.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev