While chatting, my phone rang suddenly.
In the sentence, the subject of the participle clause is different from that of the main clause. I'd like to know whether it is grammatical.
Typically, the subject should be the same in both the main and participle phrase (clause), otherwise your sentence might suggest that your phone was chatting.
However, considering that the phones don't chat the sentence is pretty fine, even if it doesn't follow strict grammar rules.