Skip to content

Gate widgets: SiteGate's confirm button does nothing, and an explicit position on a gate layout throws #679

Description

@ashyablok-cs

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions