mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-11 02:23:19 -04:00
Add allowed_file_extensions arg to file_upload
Safari has a bug where it stops input[type=file] elements working if they don't specify the types of file to accept (via the `accept` attribute). It seems to just effect certain versions of Mojave but completely blocks this action so worth fixing. This adds a 'allowed_file_extensions' keyword argument to the file_upload component to let you specify a value to be passed to `accept`. This was spotted on x-gov Slack: https://ukgovernmentdigital.slack.com/archives/C06GCJW7R/p1607952390112800 ...and StackOverflow: https://stackoverflow.com/q/64843459/679924
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
{% macro file_upload(
|
{% macro file_upload(
|
||||||
field,
|
field,
|
||||||
|
allowed_file_extensions,
|
||||||
action=None,
|
action=None,
|
||||||
button_text="Choose file",
|
button_text="Choose file",
|
||||||
alternate_link=None,
|
alternate_link=None,
|
||||||
@@ -25,7 +26,8 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</label>
|
</label>
|
||||||
{{ field(**{
|
{{ field(**{
|
||||||
'class': 'file-upload-field'
|
'class': 'file-upload-field',
|
||||||
|
'accept': allowed_file_extensions
|
||||||
}) }}
|
}) }}
|
||||||
<label class="file-upload-button" for="{{ field.name }}">
|
<label class="file-upload-button" for="{{ field.name }}">
|
||||||
{{ button_text }}
|
{{ button_text }}
|
||||||
|
|||||||
Reference in New Issue
Block a user