From d9ca4a6668ebe3620cd9fb1bc986c08750237908 Mon Sep 17 00:00:00 2001 From: eyelidlessness Date: Tue, 7 Jun 2022 15:42:36 -0700 Subject: [PATCH] Fix: ensure geopicker is loaded for non-nested setgeopoint actions --- src/widget/geo/geopicker.js | 2 +- test/spec/widget.geo.spec.js | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/widget/geo/geopicker.js b/src/widget/geo/geopicker.js index ea0baec7b..35b1dfc46 100644 --- a/src/widget/geo/geopicker.js +++ b/src/widget/geo/geopicker.js @@ -77,7 +77,7 @@ class Geopicker extends Widget { * @type {string} */ static get selector() { - return ':is(.question input[data-type-xml="geopoint"], .question input[data-type-xml="geotrace"], .question input[data-type-xml="geoshape"]):not([data-setvalue], [data-setgeopoint])'; + return '.question [name]:not([name=""], [type="hidden"]):is(input[data-type-xml="geopoint"], input[data-type-xml="geotrace"], input[data-type-xml="geoshape"])'; } /** diff --git a/test/spec/widget.geo.spec.js b/test/spec/widget.geo.spec.js index f1f1a69e3..8014a2dba 100644 --- a/test/spec/widget.geo.spec.js +++ b/test/spec/widget.geo.spec.js @@ -132,4 +132,28 @@ describe('geoshape widget', () => { expect(geopickers.length).to.equal(0); }); + + it('loads the widget when a setgeopoint odk-instance-first-load action is defined adjacent to the input', () => { + const form = loadForm('setgeopoint.xml'); + + form.init(); + + const widget = form.view.html.querySelector( + '[name="/data/visible_first_load_adjacent_action"] ~ .geopicker' + ); + + expect(widget).not.to.be.null; + }); + + it('loads the widget when a setgeopoint odk-instance-first-load action is defined in the model', () => { + const form = loadForm('setgeopoint.xml'); + + form.init(); + + const widget = form.view.html.querySelector( + '[name="/data/visible_first_load_model_action"] ~ .geopicker' + ); + + expect(widget).not.to.be.null; + }); });