This use of which is grammatical and is commonly employed in spoken or informal English.
This type of which-clause is different than the one we use to modify a preceding non-person noun; this one modifies an entire proposition.
Some examples should make this clearer. Here is a which-clause modifying a preceding non-person noun:
The goat was standing on the roof of the house, which was abandoned.
Here is a which-clause modifying a proposition:
The goat was standing on the roof of the house, which didn't make sense.1
We can look at it another way . . . Here is a who-clause modifying a preceding person noun.
The people were dissatisfied with their leader, who was soon fired.
Here is a which-clause modifying a proposition:
The people were dissatisfied with their leader, which was warranted.
Not:
*The people were dissatisfied with their leader, who was warranted. (incorrect)
The OED specifically calls out this usage:
which, pron. and adj.
III. Relative uses . . . 7. pron. c. Referring to a fact, circumstance, or statement. Now very common in spoken
English.
Source: Oxford English
Dictionary (login required)
1. Goat sentence examples from Grammar-Quizzes.com: Which Clauses—Modify the preceding noun versus the idea of the entire clause.