diff --git a/app/javascript/controllers/format_controller.ts b/app/javascript/controllers/format_controller.ts index da1dcacce..f5ce0227d 100644 --- a/app/javascript/controllers/format_controller.ts +++ b/app/javascript/controllers/format_controller.ts @@ -54,6 +54,6 @@ export class FormatController extends ApplicationController { const decimalSeparator = value.lastIndexOf(',') > value.lastIndexOf('.') ? ',' : '.'; - return value.replace(new RegExp(`[^\\d${decimalSeparator}]`, 'g'), ''); + return value.replace(new RegExp(`[^-?\\d${decimalSeparator}]`, 'g'), ''); } } diff --git a/spec/system/users/brouillon_spec.rb b/spec/system/users/brouillon_spec.rb index f0cb9c2c4..d5ca28594 100644 --- a/spec/system/users/brouillon_spec.rb +++ b/spec/system/users/brouillon_spec.rb @@ -199,6 +199,11 @@ describe 'The user' do wait_until { champ_value_for('nombre décimal') == '1234.56' } + + fill_in('nombre décimal', with: '-1,234.56') + wait_until { + champ_value_for('nombre décimal') == '-1234.56' + } end scenario 'extends dossier experation date more than one time, ', js: true, retry: 3 do