## 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/test/test_event_model.py
from unittest.mock import call, patch
from posthog.api.test.base import BaseTest
from posthog.models import Action, ActionStep, Element, ElementGroup, Event, Person, Team
from posthog.models.event import Selector, SelectorPart
class TestFilterByActions(BaseTest):
    def test_filter_with_selectors(self):
        Person.objects.create(distinct_ids=["whatever"], team=self.team)
        event1 = Event.objects.create(
            event="$autocapture",
            team=self.team,
            distinct_id="whatever",
            elements=[
                Element(tag_name="a", href="/a-url", nth_child=1, nth_of_type=0),
                Element(tag_name="button", nth_child=0, nth_of_type=0),
                Element(tag_name="div", nth_child=0, nth_of_type=0),
                Element(tag_name="div", nth_child=0, nth_of_type=0, attr_id="nested",),
            ],