To be fair, what would be illegal (actually, in many countries I'd say not illegal, but against school regulations) would be them actually dating. Being a love interest is NOT illegal.
Sensei can't teach me love ( https://mangadex.org/title/32726/sensei-wa-koi-o-oshierarenai ) has a similar premise. The teacher and student are "dating" but not really, it's platonic until he graduates.