prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Pushing a screen should send Leave message
  If you have an action that opens a screen, it leaves the footer stuck in the highlight state.
  
  I think we need to call `_set_mouse_over(None)` on the current screen when pushing another screen.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/textual/widgets/_footer.py`
  Content:
  ```
  1 from __future__ import annotations
  2 
  3 from collections import defaultdict
  4 from typing import ClassVar, Optional
  5 
  6 import rich.repr
  7 from rich.console import RenderableType
  8 from rich.text import Text
  9 
  10 from .. import events
  11 from ..reactive import reactive
  12 from ..widget import Widget
  13 
  14 
  15 @rich.repr.auto
  16 class Footer(Widget):
  17     """A simple footer widget which docks itself to the bottom of the parent container."""
  18 
  19     COMPONENT_CLASSES: ClassVar[set[str]] = {
  20         "footer--description",
  21         "footer--key",
  22         "footer--highlight",
  23         "footer--highlight-key",
  24     }
  25     """
  26     | Class | Description |
  27     | :- | :- |
  28     | `footer--description` | Targets the descriptions of the key bindings. |
  29     | `footer--highlight` | Targets the highlighted key binding. |
  30     | `footer--highlight-key` | Targets the key portion of the highlighted key binding. |
  31     | `footer--key` | Targets the key portions of the key bindings. |
  32     """
  33 
  34     DEFAULT_CSS = """
  35     Footer {
  36         background: $accent;
  37         color: $text;
  38         dock: bottom;
  39         height: 1;
  40     }
  41     Footer > .footer--highlight {
  42         background: $accent-darken-1;
  43     }
  44 
  45     Footer > .footer--highlight-key {
  46         background: $secondary;
  47         text-style: bold;
  48     }
  49 
  50     Footer > .footer--key {
  51         text-style: bold;
  52         background: $accent-darken-2;
  53     }
  54     """
  55 
  56     highlight_key: reactive[str | None] = reactive[Optional[str]](None)
  57 
  58     def __init__(self) -> None:
  59         super().__init__()
  60         self._key_text: Text | None = None
  61         self.auto_links = False
  62 
  63     async def watch_highlight_key(self) -> None:
  64         """If highlight key changes we need to regenerate the text."""
  65         self._key_text = None
  66         self.refresh()
  67 
  68     def _on_mount(self, _: events.Mount) -> None:
  69         self.watch(self.screen, "focused", self._bindings_changed)
  70         self.watch(self.screen, "stack_updates", self._bindings_changed)
  71 
  72     def _bindings_changed(self, _: Widget | None) -> None:
  73         self._key_text = None
  74         self.refresh()
  75 
  76     def _on_mouse_move(self, event: events.MouseMove) -> None:
  77         """Store any key we are moving over."""
  78         self.highlight_key = event.style.meta.get("key")
  79 
  80     def _on_leave(self, _: events.Leave) -> None:
  81         """Clear any highlight when the mouse leaves the widget"""
  82         if self.screen.is_current:
  83             self.highlight_key = None
  84 
  85     def __rich_repr__(self) -> rich.repr.Result:
  86         yield from super().__rich_repr__()
  87 
  88     def _make_key_text(self) -> Text:
  89         """Create text containing all the keys."""
  90         base_style = self.rich_style
  91         text = Text(
  92             style=self.rich_style,
  93             no_wrap=True,
  94             overflow="ellipsis",
  95             justify="left",
  96             end="",
  97         )
  98         highlight_style = self.get_component_rich_style("footer--highlight")
  99         highlight_key_style = self.get_component_rich_style("footer--highlight-key")
  100         key_style = self.get_component_rich_style("footer--key")
  101         description_style = self.get_component_rich_style("footer--description")
  102 
  103         bindings = [
  104             binding
  105             for (_, binding) in self.app.namespace_bindings.values()
  106             if binding.show
  107         ]
  108 
  109         action_to_bindings = defaultdict(list)
  110         for binding in bindings:
  111             action_to_bindings[binding.action].append(binding)
  112 
  113         for _, bindings in action_to_bindings.items():
  114             binding = bindings[0]
  115             if binding.key_display is None:
  116                 key_display = self.app.get_key_display(binding.key)
  117                 if key_display is None:
  118                     key_display = binding.key.upper()
  119             else:
  120                 key_display = binding.key_display
  121             hovered = self.highlight_key == binding.key
  122             key_text = Text.assemble(
  123                 (f" {key_display} ", highlight_key_style if hovered else key_style),
  124                 (
  125                     f" {binding.description} ",
  126                     highlight_style if hovered else base_style + description_style,
  127                 ),
  128                 meta={
  129                     "@click": f"app.check_bindings('{binding.key}')",
  130                     "key": binding.key,
  131                 },
  132             )
  133             text.append_text(key_text)
  134         return text
  135 
  136     def notify_style_update(self) -> None:
  137         self._key_text = None
  138 
  139     def post_render(self, renderable):
  140         return renderable
  141 
  142     def render(self) -> RenderableType:
  143         if self._key_text is None:
  144             self._key_text = self._make_key_text()
  145         return self._key_text
  146
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/textual/widgets/_footer.py b/src/textual/widgets/_footer.py
  --- a/src/textual/widgets/_footer.py
  +++ b/src/textual/widgets/_footer.py
  @@ -79,8 +79,7 @@
   
       def _on_leave(self, _: events.Leave) -> None:
           """Clear any highlight when the mouse leaves the widget"""
  -        if self.screen.is_current:
  -            self.highlight_key = None
  +        self.highlight_key = None
   
       def __rich_repr__(self) -> rich.repr.Result:
           yield from super().__rich_repr__()
  
verification_info: {"golden_diff": "diff --git a/src/textual/widgets/_footer.py b/src/textual/widgets/_footer.py\n--- a/src/textual/widgets/_footer.py\n+++ b/src/textual/widgets/_footer.py\n@@ -79,8 +79,7 @@\n \n     def _on_leave(self, _: events.Leave) -> None:\n         \"\"\"Clear any highlight when the mouse leaves the widget\"\"\"\n-        if self.screen.is_current:\n-            self.highlight_key = None\n+        self.highlight_key = None\n \n     def __rich_repr__(self) -> rich.repr.Result:\n         yield from super().__rich_repr__()\n", "issue": "Pushing a screen should send Leave message\nIf you have an action that opens a screen, it leaves the footer stuck in the highlight state.\n\nI think we need to call `_set_mouse_over(None)` on the current screen when pushing another screen.\n", "before_files": [{"content": "from __future__ import annotations\n\nfrom collections import defaultdict\nfrom typing import ClassVar, Optional\n\nimport rich.repr\nfrom rich.console import RenderableType\nfrom rich.text import Text\n\nfrom .. import events\nfrom ..reactive import reactive\nfrom ..widget import Widget\n\n\n@rich.repr.auto\nclass Footer(Widget):\n    \"\"\"A simple footer widget which docks itself to the bottom of the parent container.\"\"\"\n\n    COMPONENT_CLASSES: ClassVar[set[str]] = {\n        \"footer--description\",\n        \"footer--key\",\n        \"footer--highlight\",\n        \"footer--highlight-key\",\n    }\n    \"\"\"\n    | Class | Description |\n    | :- | :- |\n    | `footer--description` | Targets the descriptions of the key bindings. |\n    | `footer--highlight` | Targets the highlighted key binding. |\n    | `footer--highlight-key` | Targets the key portion of the highlighted key binding. |\n    | `footer--key` | Targets the key portions of the key bindings. |\n    \"\"\"\n\n    DEFAULT_CSS = \"\"\"\n    Footer {\n        background: $accent;\n        color: $text;\n        dock: bottom;\n        height: 1;\n    }\n    Footer > .footer--highlight {\n        background: $accent-darken-1;\n    }\n\n    Footer > .footer--highlight-key {\n        background: $secondary;\n        text-style: bold;\n    }\n\n    Footer > .footer--key {\n        text-style: bold;\n        background: $accent-darken-2;\n    }\n    \"\"\"\n\n    highlight_key: reactive[str | None] = reactive[Optional[str]](None)\n\n    def __init__(self) -> None:\n        super().__init__()\n        self._key_text: Text | None = None\n        self.auto_links = False\n\n    async def watch_highlight_key(self) -> None:\n        \"\"\"If highlight key changes we need to regenerate the text.\"\"\"\n        self._key_text = None\n        self.refresh()\n\n    def _on_mount(self, _: events.Mount) -> None:\n        self.watch(self.screen, \"focused\", self._bindings_changed)\n        self.watch(self.screen, \"stack_updates\", self._bindings_changed)\n\n    def _bindings_changed(self, _: Widget | None) -> None:\n        self._key_text = None\n        self.refresh()\n\n    def _on_mouse_move(self, event: events.MouseMove) -> None:\n        \"\"\"Store any key we are moving over.\"\"\"\n        self.highlight_key = event.style.meta.get(\"key\")\n\n    def _on_leave(self, _: events.Leave) -> None:\n        \"\"\"Clear any highlight when the mouse leaves the widget\"\"\"\n        if self.screen.is_current:\n            self.highlight_key = None\n\n    def __rich_repr__(self) -> rich.repr.Result:\n        yield from super().__rich_repr__()\n\n    def _make_key_text(self) -> Text:\n        \"\"\"Create text containing all the keys.\"\"\"\n        base_style = self.rich_style\n        text = Text(\n            style=self.rich_style,\n            no_wrap=True,\n            overflow=\"ellipsis\",\n            justify=\"left\",\n            end=\"\",\n        )\n        highlight_style = self.get_component_rich_style(\"footer--highlight\")\n        highlight_key_style = self.get_component_rich_style(\"footer--highlight-key\")\n        key_style = self.get_component_rich_style(\"footer--key\")\n        description_style = self.get_component_rich_style(\"footer--description\")\n\n        bindings = [\n            binding\n            for (_, binding) in self.app.namespace_bindings.values()\n            if binding.show\n        ]\n\n        action_to_bindings = defaultdict(list)\n        for binding in bindings:\n            action_to_bindings[binding.action].append(binding)\n\n        for _, bindings in action_to_bindings.items():\n            binding = bindings[0]\n            if binding.key_display is None:\n                key_display = self.app.get_key_display(binding.key)\n                if key_display is None:\n                    key_display = binding.key.upper()\n            else:\n                key_display = binding.key_display\n            hovered = self.highlight_key == binding.key\n            key_text = Text.assemble(\n                (f\" {key_display} \", highlight_key_style if hovered else key_style),\n                (\n                    f\" {binding.description} \",\n                    highlight_style if hovered else base_style + description_style,\n                ),\n                meta={\n                    \"@click\": f\"app.check_bindings('{binding.key}')\",\n                    \"key\": binding.key,\n                },\n            )\n            text.append_text(key_text)\n        return text\n\n    def notify_style_update(self) -> None:\n        self._key_text = None\n\n    def post_render(self, renderable):\n        return renderable\n\n    def render(self) -> RenderableType:\n        if self._key_text is None:\n            self._key_text = self._make_key_text()\n        return self._key_text\n", "path": "src/textual/widgets/_footer.py"}], "after_files": [{"content": "from __future__ import annotations\n\nfrom collections import defaultdict\nfrom typing import ClassVar, Optional\n\nimport rich.repr\nfrom rich.console import RenderableType\nfrom rich.text import Text\n\nfrom .. import events\nfrom ..reactive import reactive\nfrom ..widget import Widget\n\n\n@rich.repr.auto\nclass Footer(Widget):\n    \"\"\"A simple footer widget which docks itself to the bottom of the parent container.\"\"\"\n\n    COMPONENT_CLASSES: ClassVar[set[str]] = {\n        \"footer--description\",\n        \"footer--key\",\n        \"footer--highlight\",\n        \"footer--highlight-key\",\n    }\n    \"\"\"\n    | Class | Description |\n    | :- | :- |\n    | `footer--description` | Targets the descriptions of the key bindings. |\n    | `footer--highlight` | Targets the highlighted key binding. |\n    | `footer--highlight-key` | Targets the key portion of the highlighted key binding. |\n    | `footer--key` | Targets the key portions of the key bindings. |\n    \"\"\"\n\n    DEFAULT_CSS = \"\"\"\n    Footer {\n        background: $accent;\n        color: $text;\n        dock: bottom;\n        height: 1;\n    }\n    Footer > .footer--highlight {\n        background: $accent-darken-1;\n    }\n\n    Footer > .footer--highlight-key {\n        background: $secondary;\n        text-style: bold;\n    }\n\n    Footer > .footer--key {\n        text-style: bold;\n        background: $accent-darken-2;\n    }\n    \"\"\"\n\n    highlight_key: reactive[str | None] = reactive[Optional[str]](None)\n\n    def __init__(self) -> None:\n        super().__init__()\n        self._key_text: Text | None = None\n        self.auto_links = False\n\n    async def watch_highlight_key(self) -> None:\n        \"\"\"If highlight key changes we need to regenerate the text.\"\"\"\n        self._key_text = None\n        self.refresh()\n\n    def _on_mount(self, _: events.Mount) -> None:\n        self.watch(self.screen, \"focused\", self._bindings_changed)\n        self.watch(self.screen, \"stack_updates\", self._bindings_changed)\n\n    def _bindings_changed(self, _: Widget | None) -> None:\n        self._key_text = None\n        self.refresh()\n\n    def _on_mouse_move(self, event: events.MouseMove) -> None:\n        \"\"\"Store any key we are moving over.\"\"\"\n        self.highlight_key = event.style.meta.get(\"key\")\n\n    def _on_leave(self, _: events.Leave) -> None:\n        \"\"\"Clear any highlight when the mouse leaves the widget\"\"\"\n        self.highlight_key = None\n\n    def __rich_repr__(self) -> rich.repr.Result:\n        yield from super().__rich_repr__()\n\n    def _make_key_text(self) -> Text:\n        \"\"\"Create text containing all the keys.\"\"\"\n        base_style = self.rich_style\n        text = Text(\n            style=self.rich_style,\n            no_wrap=True,\n            overflow=\"ellipsis\",\n            justify=\"left\",\n            end=\"\",\n        )\n        highlight_style = self.get_component_rich_style(\"footer--highlight\")\n        highlight_key_style = self.get_component_rich_style(\"footer--highlight-key\")\n        key_style = self.get_component_rich_style(\"footer--key\")\n        description_style = self.get_component_rich_style(\"footer--description\")\n\n        bindings = [\n            binding\n            for (_, binding) in self.app.namespace_bindings.values()\n            if binding.show\n        ]\n\n        action_to_bindings = defaultdict(list)\n        for binding in bindings:\n            action_to_bindings[binding.action].append(binding)\n\n        for _, bindings in action_to_bindings.items():\n            binding = bindings[0]\n            if binding.key_display is None:\n                key_display = self.app.get_key_display(binding.key)\n                if key_display is None:\n                    key_display = binding.key.upper()\n            else:\n                key_display = binding.key_display\n            hovered = self.highlight_key == binding.key\n            key_text = Text.assemble(\n                (f\" {key_display} \", highlight_key_style if hovered else key_style),\n                (\n                    f\" {binding.description} \",\n                    highlight_style if hovered else base_style + description_style,\n                ),\n                meta={\n                    \"@click\": f\"app.check_bindings('{binding.key}')\",\n                    \"key\": binding.key,\n                },\n            )\n            text.append_text(key_text)\n        return text\n\n    def notify_style_update(self) -> None:\n        self._key_text = None\n\n    def post_render(self, renderable):\n        return renderable\n\n    def render(self) -> RenderableType:\n        if self._key_text is None:\n            self._key_text = self._make_key_text()\n        return self._key_text\n", "path": "src/textual/widgets/_footer.py"}]}