Ensure that the baseDir for createNewItem is within the project.

This is a fix for #9910.
No, we can't just return null. We need to fix it below to the project root since the caller is expecting a valid director in the project.