The sunshade can be opened and closed by hand.
The sunshade opens automatically when the moonroof is opened, but must be closed by hand.

CAUTION
Jam-safe Moonroof
Security SystemMazda 6 Owners Manual: Cruise actuator removal/installation
1. Disconnect the negative battery cable.
2. Remove in the order indicated in the table.
3. Install in the reverse order of removal.
Cover Removal Note
Unclamp the clips of the heater hoses at the front of the cover.
...
Mazda 6 Owners Manual: Front drain hose installation
Caution
If the front drain hose is pinched or bent anywhere, the water in the hose
may not discharge and enter the inside of the vehicle. During and after
installation of the trims and the headliner, always make sure there is no
interference with the front drain hose. Fix any problem if found ...