What are the steps required to reproduce the bug?
- Install a new Drupal instance
- Add an additional language (e.g. italian)
- Use URL negotiation and configure path prefixes (e.g. /en for english and /it for italian)
- Enable the language selector for content type
- Create new node using "not specified" as language
- Go to /it/admin/content
What behavior were you expecting?
The main link to the entity inside the content table should link to /it/node/1 (the current user interface language based on the url /it/admin/content).
What happened instead?
The main link to the entity inside the content table links to /node/1, which changes the site language (based on language path prefix) back to english.
I added a simple patch, but I'm not sure about consequences outside the described use-case.
The $entity->toURL() method adds the entities current language as an URL option to the link generator. The provided patch applies the current language as a prefix base if the nodes language is "not specified".