Skip to content

Create button disabled on /events/new page when LANGUAGES contains unsupported datepicker locales #205

@bamsejon

Description

@bamsejon

Bug Description

When using the /events/new page to create a new event, the "Create" button is permanently disabled and events cannot be created. The "Quick event" feature on the dashboard works correctly.

Environment

  • Claper version: latest from dev branch
  • Deployment: Kubernetes
  • LANGUAGES env var: en,sv (Swedish)

Root Cause

The bug is in assets/js/app.js. When the LANGUAGES environment variable includes locales that aren't imported from air-datepicker (like Swedish "sv"), the datepicker initialization crashes.

Technical Details

  1. window.claperConfig.supportedLocales is set from the LANGUAGES env var (e.g., ["en", "sv"])

  2. The code checks if the locale is in airdatePickrSupportedLocales (line 76-78):

    if (!airdatePickrSupportedLocales.includes(locale)) {
      airdatepickrLocale = "en";
    }
  3. But airdatePickrSupportedLocales comes from window.claperConfig.supportedLocales, NOT from the actual available locales in airdatePickrLocales

  4. The airdatePickrLocales object only has: en, fr, de, es, nl, it, hu

  5. So when locale is "sv":

    • "sv" IS in airdatePickrSupportedLocales (from config)
    • But "sv" is NOT a key in airdatePickrLocales (no Swedish import)
    • airdatePickrLocales["sv"] returns undefined
    • AirDatepicker's _handleLocale crashes with: "undefined" is not valid JSON
  6. This JavaScript error prevents the form validation from completing, keeping the Create button disabled.

Console Error

SyntaxError: "undefined" is not valid JSON
    at JSON.parse (<anonymous>)
    at _handleLocale (datepicker.js:291)

Reproduction Steps

  1. Deploy Claper with LANGUAGES=en,sv (or any locale not in the current imports)
  2. Log in and go to /events/new
  3. Fill in all required fields
  4. Observe that the Create button remains disabled
  5. Open browser console to see the JavaScript error

Workaround

Use the "Quick event" button from the dashboard which uses a different code path.

Suggested Fix

  1. Add more locale imports from air-datepicker (sv, da, nb, fi, pl, pt, ru, uk, cs, ja, zh, ko are all available)
  2. Change the fallback check to verify locale exists in airdatePickrLocales keys, not just in supportedLocales

I'll submit a PR with the fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions