-
-
Notifications
You must be signed in to change notification settings - Fork 122
Description
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
-
window.claperConfig.supportedLocalesis set from theLANGUAGESenv var (e.g.,["en", "sv"]) -
The code checks if the locale is in
airdatePickrSupportedLocales(line 76-78):if (!airdatePickrSupportedLocales.includes(locale)) { airdatepickrLocale = "en"; }
-
But
airdatePickrSupportedLocalescomes fromwindow.claperConfig.supportedLocales, NOT from the actual available locales inairdatePickrLocales -
The
airdatePickrLocalesobject only has: en, fr, de, es, nl, it, hu -
So when locale is "sv":
- "sv" IS in
airdatePickrSupportedLocales(from config) - But "sv" is NOT a key in
airdatePickrLocales(no Swedish import) airdatePickrLocales["sv"]returnsundefined- AirDatepicker's
_handleLocalecrashes with:"undefined" is not valid JSON
- "sv" IS in
-
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
- Deploy Claper with
LANGUAGES=en,sv(or any locale not in the current imports) - Log in and go to
/events/new - Fill in all required fields
- Observe that the Create button remains disabled
- 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
- Add more locale imports from air-datepicker (sv, da, nb, fi, pl, pt, ru, uk, cs, ja, zh, ko are all available)
- Change the fallback check to verify locale exists in
airdatePickrLocaleskeys, not just insupportedLocales
I'll submit a PR with the fix.