When the locale of the DatePickerInput component is set to "de" (German), the functionality to add an automatic date separator ("." in the case of the German locale) is broken. Instead of appending a dot to the first two characters entered, the input gets changed to a single dot. Subsequently, any numbers entered are concatenated without the proper separator.
Solution:
I found the usage of the RegExp constructor to create regular expressions. One of the supported date separator is . (dd.mm.yyyy). The dot character is a metacharacter in regular expressions which needs to be escaped if it is being passed into the RegExp constructor. In this code block, it was not escaped. Hence the code
Issue:
When the locale of the DatePickerInput component is set to "de" (German), the functionality to add an automatic date separator ("." in the case of the German locale) is broken. Instead of appending a dot to the first two characters entered, the input gets changed to a single dot. Subsequently, any numbers entered are concatenated without the proper separator.
Solution:
I found the usage of the
RegExp
constructor to create regular expressions. One of the supported date separator is.
(dd.mm.yyyy). Thedot
character is ametacharacter
in regular expressions which needs to be escaped if it is being passed into theRegExp
constructor. In this code block, it was not escaped. Hence the codeyielded a different regex than the expected one.
Fixes DatePickerInput component breaks automatic date separator when setting locale to "de"