Filter nodes by entity reference
Here is the my solution inspired from:


http://www.webomelette.com/creating-custom-views-filter-drupal-8
http://www.sitepoint.com/drupal-8-version-entityfieldquery/


Thanks to Danny Sipos

I already had a dedicated custom module for this project where I added the following:

mymodule.views.inc

&lt;?php
/**
 * Implements hook_views_data_alter().
 */
function mymodule_views_data_alter(array &amp;$data)
{
    $data['node_field_data']['related_content_titles'] = array(
        'title' =&gt; t('Related content titles'),
        'filter' =&gt; array(
            'title' =&gt; t('Related content titles'),
            'help' =&gt; t('Specify a list of titles an content node can have.'),
            'field' =&gt; 'nid',
            'id' =&gt; 'mymodule_related_content_titles'
        ),
    );
}


src/Plugin/views/filter/RelatedContentTitles.php



use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\filter\ManyToOne;
use Drupal\views\ViewExecutable;

/**
 * Filters by given list of event title options.
 *
 * @ingroup views_filter_handlers
 *
 * @ViewsFilter("mymodule_related_content_titles")
 */
class RelatedContentTitles extends ManyToOne
{
    /**
     * {@inheritdoc}
     */
    public function init(ViewExecutable $view, DisplayPluginBase $display, array &amp;$options = NULL)
    {
        parent::init($view, $display, $options);
        $this-&gt;valueTitle = t('Allowed event titles');
        $this-&gt;definition['options callback'] = array($this, 'generateOptions');
    }

    /**
     * Helper function that generates the options.
     * @return array
     */
    public function generateOptions()
    {
        $storage = \Drupal::entityManager()-&gt;getStorage('node');

        $relatedContentQuery = \Drupal::entityQuery('node')
            -&gt;condition('type', array('event', 'story'), 'IN')
            -&gt;condition('status', 1);

        $relatedContentIds = $relatedContentQuery-&gt;execute();

        $res = array();
        foreach ($relatedContentIds as $contentId) {
            $res[$contentId] = $storage-&gt;load($contentId)-&gt;getTitle();
        }

        return $res;
    }
}


When ceating the view listing my articles where I want to expose the related event filter I had to :


add a relationship field_article_associated_event: Content
add a filter criteria of my type Related content titles, select the perviously cerated relationship for the field Relationshi, check Expose this filter to visitors, to allow them to change it