## 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
with transaction.atomic():
            if kwargs.get("elements"):
                if kwargs.get("team"):
                    kwargs["elements_hash"] = ElementGroup.objects.create(
                        team=kwargs["team"], elements=kwargs.pop("elements")
                    ).hash
                else:
                    kwargs["elements_hash"] = ElementGroup.objects.create(
                        team_id=kwargs["team_id"], elements=kwargs.pop("elements")
                    ).hash
            event = super().create(*args, **kwargs)
            
            
            
            if not settings.ASYNC_EVENT_ACTION_MAPPING:
                should_post_webhook = False
                relations = []
                for action in event.actions:
                    relations.append(action.events.through(action_id=action.pk, event_id=event.pk))
                    action.on_perform(event)
                    if action.post_to_slack:
                        should_post_webhook = True
                Action.events.through.objects.bulk_create(relations, ignore_conflicts=True)
                team = kwargs.get("team", event.team)
                if should_post_webhook and team and team.slack_incoming_webhook:
                    celery.current_app.send_task("posthog.tasks.webhooks.post_event_to_webhook", (event.pk, site_url))
            return event
class Event(models.Model):