Empty but we are prev so just go back to previous selection

Stephen Paul Weber created

Change summary

lib/registration.rb | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

Detailed changes

lib/registration.rb 🔗

@@ -641,7 +641,7 @@ class Registration
 			end
 
 			def next_step(iq)
-				subdomain = iq.form.field("subdomain")&.value
+				subdomain = empty_nil(iq.form.field("subdomain")&.value)
 				domain = "#{subdomain}.snikket.chat"
 				if iq.form.field(ACTION_VAR)&.value == "custom_domain"
 					CustomDomain.new(@customer, @tel, old: @old).write
@@ -676,6 +676,10 @@ class Registration
 				end
 			end
 
+			def empty_nil(s)
+				s.nil? || s.empty? ? nil : s
+			end
+
 			class NeedsDNS < Snikket
 				def initialize(customer, instance, tel, records, db: DB)
 					@customer = customer
@@ -784,7 +788,7 @@ class Registration
 					if iq.prev?
 						Snikket.new(@customer, @tel, db: @db, old: @old).write
 					else
-						launch(iq.form.field("domain")&.value)
+						launch(empty_nil(iq.form.field("domain")&.value) || @old&.domain)
 					end
 				end
 			end