File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55The format is based on [ Keep a Changelog] ( http://keepachangelog.com/ )
66and this project adheres to [ Semantic Versioning] ( http://semver.org/ ) .
77
8+ ## Unreleased
9+
10+ ### Fixed
11+
12+ - Fixed bindings persistance https://github.com/Textualize/textual/issues/1613
13+
814## [ 0.17.1] - 2023-03-30
915
1016### Fixed
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
33from dataclasses import dataclass
4- from typing import TYPE_CHECKING , Iterable , MutableMapping
4+ from typing import TYPE_CHECKING , Iterable
55
66import rich .repr
77
@@ -92,12 +92,22 @@ def make_bindings(bindings: Iterable[BindingType]) -> Iterable[Binding]:
9292 priority = binding .priority ,
9393 )
9494
95- self .keys : MutableMapping [str , Binding ] = (
95+ self .keys : dict [str , Binding ] = (
9696 {binding .key : binding for binding in make_bindings (bindings )}
9797 if bindings
9898 else {}
9999 )
100100
101+ def copy (self ) -> Bindings :
102+ """Return a copy of this instance.
103+
104+ Return:
105+ New bindings object.
106+ """
107+ copy = Bindings ()
108+ copy .keys = self .keys .copy ()
109+ return copy
110+
101111 def __rich_repr__ (self ) -> rich .repr .Result :
102112 yield self .keys
103113
Original file line number Diff line number Diff line change @@ -165,7 +165,11 @@ def __init__(
165165 self ._auto_refresh : float | None = None
166166 self ._auto_refresh_timer : Timer | None = None
167167 self ._css_types = {cls .__name__ for cls in self ._css_bases (self .__class__ )}
168- self ._bindings = self ._merged_bindings or Bindings ()
168+ self ._bindings = (
169+ Bindings ()
170+ if self ._merged_bindings is None
171+ else self ._merged_bindings .copy ()
172+ )
169173 self ._has_hover_style : bool = False
170174 self ._has_focus_within : bool = False
171175
You can’t perform that action at this time.
0 commit comments