Remove the "comma" number separator from the Id field

System Information
  • Strapi Version: v4.4.7
  • Operating System: Linux
  • Database: Mysql
  • Node Version: 16
  • NPM Version: 8
  • Yarn Version:

In the admin panel in a collection list view, we see a comma separator on the Id field. e.g. id: “12345” is displayed at “12,345”. Does anyone know how to remove the commas from this field?

5 Likes

Did you ever find a solution to this? I am experiencing the same issue.

1 Like

Looking for this as well. I am trying to enter years and currently the date field does not allow for just a year. So having to use an integer. But you guessed it, in admin panel it shows 2,023 instead of 2023 lol

1 Like

We still haven’t found a solution to this. I guess it’s time to read the source code. Probably a locale issue.

2 Likes

I just came across this. I’ll take a look too. Seems to be something within the admin UI that is doing this as the data that is shown in the api has no commas obviously. This should be added as an option in the view settings.

Ill track this in case you find anything before me!

1 Like

I have also been looking for a solution to this. I am surprised it is not a configurable view option.

1 Like

While strapi is amazing, there are things like this that leave a lot to be desired. Dynamic zones in components for one. lol

Havent looked into this yet but will post my findings when I do.

1 Like

Confirming this is still and issue.

1 Like

Since i love Strapi, I can’t believe this doesn’t have a solution yet.
I have the same problem as all of you, I have a field representing the year. It’s an integer like 2023, but it displays: 2, 023 :slight_smile:
There really is no solution for this?

1 Like

Also looking for a solution…

Use patch-package to change lines 35 and 36 in this file./node_modules/@strapi/design-system/dist/NumberInput/NumberInput.mjs to this:

    const numberParserRef = useRef(new NumberParser(locale, { useGrouping: false }));
    const numberFormaterRef = useRef(new NumberFormatter(locale, { maximumFractionDigits: 20, useGrouping: false }));

This isn’t the ideal solution but it works.

The better solution is to use the webpack feature like so:

1- Rename webpack.config.example.js to webpack.config.js in the src/admin/ folder.
2- Add the following to it:

'use strict';

/* eslint-disable no-unused-vars */
module.exports = (config, webpack) => {
  // Replace Built-in NumberInput to remove comma
  config.plugins.push(new webpack.NormalModuleReplacementPlugin(/.*design-system\/dist\/NumberInput\/NumberInput\.mjs$/, `${__dirname}/webpack/CustomNumberInput.mjs`));
  return config;
};

2- Copy the file ./node_modules/@strapi/design-system/dist/NumberInput/NumberInput.mjs to src/admin/webpack/ as CustomNumberInput.mjs
4- Change the lines as described above

1 Like

I’m using this solution but it doesn’t work, do you know when the change will happen? (when running strapi develop or strapi build?)

The webpack solution will take effect when rebuilding the admin panel with strapi build, but the patch solution will only work when reinstalling the node modules with npm install or yarn install .

it seems like mine not working, maybe wrong regex or something wrong with the webpack config in my code

it’s working tough with the patch solution, it think something wrong with the webpack configuration

This repo uses the webpack solution. Compare it with yours.

@Edgy’s webpack solution here Remove the "comma" number separator from the Id field - #12 by Edgy worked for me on Strapi v4.19.1, also with strapi develop (at least, after I did strapi build once).

I had to make one change to webpack.config.js’s way of accessing webpack because I got an error (problem & solution ref):

"use strict";
const webpack = require("webpack");

/* eslint-disable no-unused-vars */
module.exports = (config) => {
	// Replace Built-in NumberInput to remove comma
	// https://forum.strapi.io/t/remove-the-comma-number-separator-from-the-id-field/24043/11
	config.plugins.push(new webpack.NormalModuleReplacementPlugin(/.*design-system\/dist\/NumberInput\/NumberInput\.mjs$/, `${__dirname}/webpack/CustomNumberInput.mjs`));
	return config;
};;
  • Even though you may be using ES modules in the rest of your project (like me), use the require import here.
  • You should still follow the rest of Edgy’s instructions.

Thanks Edgy!