## Bug description

*Please describe.*  
*If this affects the front-end, screenshots would be of great help.*  

Trailing spaces in the selector box are not removed automatically and can mess up the event results when saving an action

## Expected behavior



## How to reproduce

1. Create a new action with any selector
2. put in a couple of spaces at the end of the line in the selector input box
3. 

## Environment

- Self-managed?
- PostHog version/commit

## Additional context



#### *Thank you* for your bug report – we love squashing them!

posthog/models/event.py
Exists,
    F,
    OuterRef,
    Prefetch,
    Q,
    QuerySet,
    Subquery,
    Value,
    signals,
)
from django.db.models.functions import TruncDay
from django.forms.models import model_to_dict
from django.utils import timezone
from psycopg2 import sql  
from posthog.constants import TREND_FILTER_TYPE_ACTIONS, TREND_FILTER_TYPE_EVENTS
from posthog.models.entity import Entity
from posthog.utils import generate_cache_key
from .action import Action
from .action_step import ActionStep
from .element import Element
from .element_group import ElementGroup
from .filter import Filter
from .person import Person, PersonDistinctId
from .team import Team
from .utils import namedtuplefetchall
attribute_regex = r"([a-zA-Z]*)\[(.*)=[\'|\"](.*)[\'|\"]\]"
LAST_UPDATED_TEAM_ACTION: Dict[int, datetime.datetime] = {}
TEAM_EVENT_ACTION_QUERY_CACHE: Dict[int, Dict[str, tuple]] = defaultdict(dict)
TEAM_ACTION_QUERY_CACHE: Dict[int, str] = {}
class SelectorPart(object):