Field focus event trigger flow

I want to implement on-focus and off-focus behavior for a field in a collection, specifically for a deeplink URL field in a Post collection.

The goal is as follows:

  • When a user begins typing in the URL field, the field enters an on-focus state.
  • Once the user moves away from the field (i.e., the field loses focus), an off-focus event is triggered.
  • At that point, a flow should be initiated to validate the entered URL.

The flow should perform an HTTP request to check if the URL returns a 200 OK status:

  • If the response is not 200, this indicates the URL is invalid.
  • Directus should then notify the user that the URL is invalid, and prevent the post from being created until a valid URL is provided.

Sounds like a cool idea for an extension. Specifically, you’re looking for a custom Interface extension.

You could probably skip the flow part as well and just make the HTTP request from the client side within the interface.

Check out the docs for guides on creating extensions.