bbaovanc I don't know if that's a bug, it's more of a "non-feature". The code blocks are currently not aware of the dark or light mode. Code highlighting is performed by the highlight.js library and we currently don't provide that library any information about dark mode.
I know highlight.js has multiple themes, so I suppose there would be a way to change the theme. I think we just use the default highlight.js theme all of the time currently. I don't remember whether anyone implemented an extension to change it manually.
I'm not sure where we should place the code for this either, because Flarum natively doesn't have a code block. It's in the TextFormatter library, but only enabled by either the bbcode or markdown extensions.