Have you got a source on that? Not questioning that it does sound like an EU thing, but it could come in handy at my current company if there's legislation on that and I can't seem to find any.
It is different country by country. In some countries if it wasn't done on a company equipment regarding your assignments the company cannot do anything about it and they cannot limit you to work on opensource/unpaid projects.
I worked for Amazon in the EU, and the rule was certainly in force. Whether or not it could be enforced is a different question, but none of us wanted to go up against Amazon's lawyers!
Amazon EU companies tend to follow blindly what is coming from the HQ. I personally experienced this. After warned the management about getting the ministry of employment involved they immediately backed down and let us implement something according to the EU law. It is the matter of knowing your position and the law.