Parent is now mandatory when creating a new BaseInstance class

This commit is contained in:
2025-11-16 17:46:44 +01:00
parent edcd3ae1a8
commit e286b60348
14 changed files with 55 additions and 38 deletions

View File

@@ -6,7 +6,7 @@ from fasthtml.components import *
from myfasthtml.controls.BaseCommands import BaseCommands
from myfasthtml.controls.helpers import Ids, mk
from myfasthtml.core.commands import Command
from myfasthtml.core.instances import MultipleInstance
from myfasthtml.core.instances import MultipleInstance, BaseInstance
from myfasthtml.core.matching_utils import subsequence_matching, fuzzy_matching
logger = logging.getLogger("Search")
@@ -22,7 +22,7 @@ class Commands(BaseCommands):
class Search(MultipleInstance):
def __init__(self,
session,
parent: BaseInstance,
_id=None,
items_names=None, # what is the name of the items to filter
items=None, # first set of items to filter
@@ -42,7 +42,7 @@ class Search(MultipleInstance):
function that returns the item as is.
:param template: Callable function to render the filtered items. Defaults to a Div rendering function.
"""
super().__init__(session, Ids.Search, _id=_id)
super().__init__(Ids.Search, parent, _id=_id)
self.items_names = items_names or ''
self.items = items or []
self.filtered = self.items.copy()