Two separate bugs in the gate layout, both found while building the widget playground in #677 and neither fixed there. Confirmed by reading the code paths on develop (v1.3.0).
1. SiteGate's confirm button never unlocks the gate
In src/rollup/widgets/actions/construct-widget-actions.js, the widgetOk.onclick handler assigns widgetAction from a switch (config.type) that covers only form and subscription:
switch (config.type) {
case 'form':
widgetAction = config.layout === 'gate' ? 'unlock' : 'submit';
break;
case 'subscription':
widgetAction = 'subscribe';
break;
}
// validate form input
if (!widgetAction || !widgetFormValidate(event)) {
return;
}
sitegate does get a widgetFormValidate — it sits alongside form and subscription in the type switch near the top of the same file that wires up the form element — so the enclosing typeof widgetFormValidate === 'function' guard is entered. But widgetAction stays undefined, so the handler returns on the very next line.
The click therefore never tracks the action, never writes the PathforaUnlocked_ storage key, and never closes the widget.
Impact: a pathfora.SiteGate cannot be dismissed at all.
Workaround: use pathfora.Form with layout: 'gate', which takes the case 'form' branch and unlocks correctly.
Repro:
var gate = new pathfora.SiteGate({
id: 'sitegate-repro',
headline: 'Sign up to continue',
msg: 'Fill this in to read on.'
});
pathfora.initializeWidgets([gate]);
// fill the form, click Confirm — nothing happens, no error, no PathforaUnlocked_ key
Fix sketch: add case 'sitegate': widgetAction = 'unlock'; break; to that switch.
2. An explicit position on a gate layout throws
src/rollup/validation/validate-widget-position.js switches on config.layout with cases for modal, slideout, bar, button and inline. There is no case 'gate', so choices stays undefined and the choices.length check below it throws:
TypeError: Cannot read properties of undefined (reading 'length')
This is unreachable by default only by accident. The one caller, setupWidgetPosition, guards with if (config.position), and the gate defaults in src/rollup/globals/reset-default-props.js set position: ''. Any config that sets a non-empty position on a gate layout hits the throw during widget construction.
Repro:
var gate = new pathfora.Form({
id: 'gate-position-repro',
layout: 'gate',
position: 'middle-center',
headline: 'Sign up to continue'
});
pathfora.initializeWidgets([gate]); // TypeError
Fix sketch: add case 'gate': choices = []; break; (matching inline), or initialise choices = [] so an unrecognised layout warns instead of throwing.
Related: #675, #677. Tracked internally as LYT-1503.
Two separate bugs in the
gatelayout, both found while building the widget playground in #677 and neither fixed there. Confirmed by reading the code paths ondevelop(v1.3.0).1.
SiteGate's confirm button never unlocks the gateIn
src/rollup/widgets/actions/construct-widget-actions.js, thewidgetOk.onclickhandler assignswidgetActionfrom aswitch (config.type)that covers onlyformandsubscription:sitegatedoes get awidgetFormValidate— it sits alongsideformandsubscriptionin the type switch near the top of the same file that wires up the form element — so the enclosingtypeof widgetFormValidate === 'function'guard is entered. ButwidgetActionstaysundefined, so the handler returns on the very next line.The click therefore never tracks the action, never writes the
PathforaUnlocked_storage key, and never closes the widget.Impact: a
pathfora.SiteGatecannot be dismissed at all.Workaround: use
pathfora.Formwithlayout: 'gate', which takes thecase 'form'branch and unlocks correctly.Repro:
Fix sketch: add
case 'sitegate': widgetAction = 'unlock'; break;to that switch.2. An explicit
positionon a gate layout throwssrc/rollup/validation/validate-widget-position.jsswitches onconfig.layoutwith cases formodal,slideout,bar,buttonandinline. There is nocase 'gate', sochoicesstaysundefinedand thechoices.lengthcheck below it throws:This is unreachable by default only by accident. The one caller,
setupWidgetPosition, guards withif (config.position), and the gate defaults insrc/rollup/globals/reset-default-props.jssetposition: ''. Any config that sets a non-emptypositionon a gate layout hits the throw during widget construction.Repro:
Fix sketch: add
case 'gate': choices = []; break;(matchinginline), or initialisechoices = []so an unrecognised layout warns instead of throwing.Related: #675, #677. Tracked internally as LYT-1503.