From 88a0142f7608fe4addc0c8ad3e59a6d1eb0fa67d Mon Sep 17 00:00:00 2001 From: Ben Meyrick Date: Wed, 10 Jul 2019 11:16:51 +0100 Subject: [PATCH] Ensure date fields are only wrapped in a fieldset if there is more than one field configured (#520) --- src/components/date-input/_macro.njk | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/date-input/_macro.njk b/src/components/date-input/_macro.njk index badade6493..620038a29f 100644 --- a/src/components/date-input/_macro.njk +++ b/src/components/date-input/_macro.njk @@ -5,6 +5,20 @@ {% set exclusiveClass = " js-exclusive-group" if params.mutuallyExclusive else "" %} + {%- set numberOfFields = 0 -%} + + {%- if params.day -%} + {%- set numberOfFields = numberOfFields + 1 -%} + {%- endif -%} + + {%- if params.month -%} + {%- set numberOfFields = numberOfFields + 1 -%} + {%- endif -%} + + {%- if params.year -%} + {%- set numberOfFields = numberOfFields + 1 -%} + {%- endif -%} + {% set fields %} {% if params.label %}

{{ params.label }}

@@ -69,7 +83,7 @@ }) %} {{ fields | safe }} {% endcall %} - {% elif params.noWrap %} + {% elif params.noWrap or numberOfFields == 1 %} {{ fields | safe }} {% else %} {% call onsFieldset({