From 5be4719ac19fe2e8b79d16736a37485ec50f8784 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Thu, 10 Sep 2026 16:58:58 +0200 Subject: [PATCH] Phone number input: Fix workaround for prefixes shared between countries (fixes #6544) --- src/pretix/base/forms/questions.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/pretix/base/forms/questions.py b/src/pretix/base/forms/questions.py index 21ea5824a4..0227d1247d 100644 --- a/src/pretix/base/forms/questions.py +++ b/src/pretix/base/forms/questions.py @@ -350,16 +350,21 @@ class WrappedPhonePrefixSelect(Select): return super().render(name, value or self.initial, *args, **kwargs) def get_context(self, name, value, attrs): - if value and self.choices[1][0] != value: - matching_choices = len([1 for p, c in self.choices if p == value]) + choices = list(self.choices) + if value and choices[1][0] != value: + matching_choices = len([1 for p, c in choices if p == value]) if matching_choices > 1: # Some countries share a phone prefix, for example +1 is used all over the Americas. # This causes a UX problem: If the default value or the existing data is +12125552368, # the widget will just show the first without an explicit country. - self.choices.insert(1, (value, value)) + self.choices = [ + choices[0], + (value, value), + *choices[1:], + ] context = super().get_context(name, value, attrs) return context