govuk-frontend
Advanced tools
Comparing version 3.2.0 to 3.3.0
@@ -17,3 +17,3 @@ [ | ||
"type": "array", | ||
"required": true, | ||
"required": false, | ||
"description": "An array of input objects with name, value and classes.", | ||
@@ -20,0 +20,0 @@ "params": [ |
@@ -801,3 +801,5 @@ (function (global, factory) { | ||
* | ||
* - The `<legend>` associated with the closest `<fieldset>` ancestor | ||
* - The `<legend>` associated with the closest `<fieldset>` ancestor, as long | ||
* as the top of it is no more than half a viewport height away from the | ||
* bottom of the input | ||
* - The first `<label>` that is associated with the input using for="inputId" | ||
@@ -817,3 +819,28 @@ * - The closest parent `<label>` | ||
if (legends.length) { | ||
return legends[0] | ||
var $candidateLegend = legends[0]; | ||
// If the input type is radio or checkbox, always use the legend if there | ||
// is one. | ||
if ($input.type === 'checkbox' || $input.type === 'radio') { | ||
return $candidateLegend | ||
} | ||
// For other input types, only scroll to the fieldset’s legend (instead of | ||
// the label associated with the input) if the input would end up in the | ||
// top half of the screen. | ||
// | ||
// This should avoid situations where the input either ends up off the | ||
// screen, or obscured by a software keyboard. | ||
var legendTop = $candidateLegend.getBoundingClientRect().top; | ||
var inputRect = $input.getBoundingClientRect(); | ||
// If the browser doesn't support Element.getBoundingClientRect().height | ||
// or window.innerHeight (like IE8), bail and just link to the label. | ||
if (inputRect.height && window.innerHeight) { | ||
var inputBottom = inputRect.top + inputRect.height; | ||
if (inputBottom - legendTop < window.innerHeight / 2) { | ||
return $candidateLegend | ||
} | ||
} | ||
} | ||
@@ -820,0 +847,0 @@ } |
{ | ||
"name": "govuk-frontend", | ||
"description": "GOV.UK Frontend contains the code you need to start building a user interface for government platforms and services.", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"main": "govuk/all.js", | ||
@@ -6,0 +6,0 @@ "sass": "govuk/all.scss", |
@@ -40,3 +40,3 @@ # GOV.UK Frontend | ||
```scss | ||
@import "node_modules/govuk-frontend/all"; | ||
@import "node_modules/govuk-frontend/govuk/all"; | ||
``` | ||
@@ -52,3 +52,3 @@ | ||
You can include Javascript for all components either by copying the `all.js` from `node_modules/govuk-frontend` into your application or referencing the file directly: | ||
You can include Javascript for all components either by copying the `all.js` from `node_modules/govuk-frontend/govuk/` into your application or referencing the file directly: | ||
@@ -55,0 +55,0 @@ ```html |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1027585
13487