Skip to content

x-topic-search and x-interaction challenges #239

@dan-searle

Description

@dan-searle

In order for x-topic-search's results to be closed when you interact with something else on the page, we need do something like this:

['focusout', 'focusin', 'click'].forEach(action => {
	document.body.addEventListener(action, event => {
		if(!componentRootNode.contains(event.target)) {
			topicSearchActions.hideResult();
		}
	});
});

(We can't just listen for the blur of the topic search input, as this will cause the search results to close when you click inside the search results (e.g. on the follow button).)

So, there's a couple of questions:

  1. What is an acceptable way for an x-dash component to add (and remove) DOM event listeners outside of themselves? (we should avoid it if we can, but in this case it seems unavoidable).
  2. How to pass a ref to a DOM node from the wrapped component to the action? E.g. the event handler has this condition: componentRootNode.contains(event.target)

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions