Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove non-operational value parameter from file upload component #5311

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

querkmachine
Copy link
Member

For security reasons, all contemporary web browsers disallow the value attribute to be set to anything other than an empty string, be that via HTML or JavaScript, effectively making it a read only attribute. This parameter has thus never actually done anything other than output a non-functioning HTML attribute value. As such, we should probably get rid of it.

Our tests for this functionality appear to have been passing because it was comparing the value of the HTML attribute against what it was set to, without regarding that the underlying API property didn't match either of them.

Changes

  • Removes the value parameter and related code from the component.
  • Removes the value parameter documentation.
  • Removes tests relating to the parameter.

Thoughts

Would we consider this a breaking change? One the one hand, it's a change to the component API that has been in place since 2017. On the other, it's been non-operational that entire time.

There's a possibility that other services or forks have implemented it, on the basis of the same (flawed) test we had and which may have their own tests fail with its removal. I'm not sure if that speculation is reason enough to consider it breaking, however.

For security reasons, file inputs cannot have the value property set to anything except for an empty string. This parameter has thus never actually worked for anything other than to output a non-functioning HTML attribute. We can probably get rid of it.
Copy link

📋 Stats

File sizes

File Size
dist/govuk-frontend-development.min.css 118.52 KiB
dist/govuk-frontend-development.min.js 43.63 KiB
packages/govuk-frontend/dist/govuk/all.bundle.js 90.19 KiB
packages/govuk-frontend/dist/govuk/all.bundle.mjs 84.69 KiB
packages/govuk-frontend/dist/govuk/all.mjs 1.05 KiB
packages/govuk-frontend/dist/govuk/govuk-frontend-component.mjs 359 B
packages/govuk-frontend/dist/govuk/govuk-frontend.min.css 118.5 KiB
packages/govuk-frontend/dist/govuk/govuk-frontend.min.js 43.62 KiB
packages/govuk-frontend/dist/govuk/i18n.mjs 5.55 KiB
packages/govuk-frontend/dist/govuk/init.mjs 4.97 KiB

Modules

File Size (bundled) Size (minified)
all.mjs 81.8 KiB 41.48 KiB
accordion.mjs 23.5 KiB 12.39 KiB
button.mjs 5.98 KiB 2.69 KiB
character-count.mjs 22.4 KiB 9.92 KiB
checkboxes.mjs 5.83 KiB 2.83 KiB
error-summary.mjs 7.89 KiB 3.46 KiB
exit-this-page.mjs 17.1 KiB 9.26 KiB
header.mjs 4.46 KiB 2.6 KiB
notification-banner.mjs 6.26 KiB 2.62 KiB
password-input.mjs 15.15 KiB 7.25 KiB
radios.mjs 4.83 KiB 2.38 KiB
service-navigation.mjs 4.46 KiB 2.69 KiB
skip-link.mjs 4.39 KiB 2.18 KiB
tabs.mjs 10.05 KiB 6.06 KiB

View stats and visualisations on the review app


Action run for 0f5188d

Copy link

Rendered HTML changes to npm package

diff --git a/packages/govuk-frontend/dist/govuk/components/file-upload/template-with-value.html b/packages/govuk-frontend/dist/govuk/components/file-upload/template-with-value.html
deleted file mode 100644
index 68d350f46..000000000
--- a/packages/govuk-frontend/dist/govuk/components/file-upload/template-with-value.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<div class="govuk-form-group">
-  <label class="govuk-label" for="file-upload-4">
-    Upload a photo
-  </label>
-  <input class="govuk-file-upload" id="file-upload-4" name="file-upload-4" type="file" value="C:&#92;fakepath&#92;myphoto.jpg">
-</div>

Action run for 0f5188d

Copy link

Other changes to npm package

diff --git a/packages/govuk-frontend/dist/govuk/components/file-upload/fixtures.json b/packages/govuk-frontend/dist/govuk/components/file-upload/fixtures.json
index 4a36de2a3..132c05002 100644
--- a/packages/govuk-frontend/dist/govuk/components/file-upload/fixtures.json
+++ b/packages/govuk-frontend/dist/govuk/components/file-upload/fixtures.json
@@ -55,22 +55,6 @@
             "screenshot": false,
             "html": "<div class=\"govuk-form-group govuk-form-group--error\">\n  <label class=\"govuk-label\" for=\"file-upload-3\">\n    Upload a file\n  </label>\n  <div id=\"file-upload-3-hint\" class=\"govuk-hint\">\n    Your photo may be in your Pictures, Photos, Downloads or Desktop folder. Or in an app like iPhoto.\n  </div>\n  <p id=\"file-upload-3-error\" class=\"govuk-error-message\">\n    <span class=\"govuk-visually-hidden\">Error:</span> Error message goes here\n  </p>\n  <input class=\"govuk-file-upload govuk-file-upload--error\" id=\"file-upload-3\" name=\"file-upload-3\" type=\"file\" aria-describedby=\"file-upload-3-hint file-upload-3-error\">\n</div>"
         },
-        {
-            "name": "with value",
-            "options": {
-                "id": "file-upload-4",
-                "name": "file-upload-4",
-                "value": "C:\\fakepath\\myphoto.jpg",
-                "label": {
-                    "text": "Upload a photo"
-                }
-            },
-            "hidden": false,
-            "description": "",
-            "previewLayoutModifiers": [],
-            "screenshot": false,
-            "html": "<div class=\"govuk-form-group\">\n  <label class=\"govuk-label\" for=\"file-upload-4\">\n    Upload a photo\n  </label>\n  <input class=\"govuk-file-upload\" id=\"file-upload-4\" name=\"file-upload-4\" type=\"file\" value=\"C:&#92;fakepath&#92;myphoto.jpg\">\n</div>"
-        },
         {
             "name": "with label as page heading",
             "options": {
diff --git a/packages/govuk-frontend/dist/govuk/components/file-upload/macro-options.json b/packages/govuk-frontend/dist/govuk/components/file-upload/macro-options.json
index 5db62cb10..63bf01af9 100644
--- a/packages/govuk-frontend/dist/govuk/components/file-upload/macro-options.json
+++ b/packages/govuk-frontend/dist/govuk/components/file-upload/macro-options.json
@@ -11,12 +11,6 @@
         "required": true,
         "description": "The ID of the input."
     },
-    {
-        "name": "value",
-        "type": "string",
-        "required": false,
-        "description": "Optional initial value of the input."
-    },
     {
         "name": "disabled",
         "type": "boolean",

Action run for 0f5188d

@querkmachine querkmachine changed the title Remove value parameter from file upload component Remove non-operational value parameter from file upload component Sep 12, 2024
@querkmachine querkmachine marked this pull request as ready for review September 13, 2024 07:38
@owenatgov
Copy link
Contributor

From a cursory search, folks are indeed using the value param, even if it's almost certainly not doing anything. Probably this is going to break tests, which isn't necessarily the end of the world but does mean we'd be putting out a knowlingly breaking change. I'm going to suggest we follow due process and deprecate this instead.

I reckon we can still remove the test and instead of removing the param from the docs, maybe just adding a note that it's deprecated or even replacing the existing docs with a deprecation note.

@querkmachine
Copy link
Member Author

Playing it safe and putting this through the deprecation and removal process. I've put this in the v6 milestone and added a PR to deprecate it here: #5330

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants