I'm new around here so don't take this code seriously but this seem to fix the problem. The animation works just find here and I'm sure you can figure out the rest.
KV = '''
MDScreen:
MDBoxLayout:
Widget:
size_hint_x: None
width: nav_rail.width
MDScreen:
Button:
id: button
text: str(self.width)
size_hint: (1, 0.1)
pos_hint: {"center_x": .5, "center_y": .5}
on_release: nav_drawer.set_state("toggle")
MDNavigationDrawer:
id: nav_drawer
radius: 0, dp(16), dp(16), 0
MDNavigationRail:
id: nav_rail
md_bg_color: (0,0,0,1)
'''