liveBook · Manning

Event propagation

As explained in Building User-Friendly DSLs

Event propagation is the process by which a DOM event is delivered from its originating element through surrounding elements in the DOM tree.

Event propagation delivers a DOM event from the clicked element through surrounding elements. In the editor, clicking a value starts editing but also bubbles to a parent handler, which selects the containing AST object. section 6.2.1

Control propagation at the handlers where nested editor actions should remain independent:

  • Call event.stopPropagation() in the DisplayValue onClick handler before enabling editing. section 6.2.1
  • Apply the same protection to the add-object button and the input element used during editing. section 6.2.1
  • Keep parent selection behavior separate by wrapping AST projections with a reusable selection component. section 6.2.3

Editing without selecting the parent

A click on a value’s <span> invokes its editing handler, then would bubble to the surrounding AST object’s selection handler. Calling event.stopPropagation() in the value handler prevents that parent selection. The same pattern keeps add-object clicks and input clicks from triggering unrelated selection behavior. section 6.2.1

How Building User-Friendly DSLs covers it

How deep it goes
Explains bubbling through surrounding DOM elements and applies stopPropagation(), without developing a broader event model.
Examples
Uses DisplayValue, AddNewButton, and editing input elements as nested click-handler examples.
What you can do after
Diagnose editor clicks that trigger unintended parent behavior and fix them with event.stopPropagation().
How it connects
Connects DOM events with event handlers, React components, AST selection, and reusable UI wrappers.

Also explained in

Compare how 4 books explain event propagation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building User-Friendly DSLs. The section links point to the parts of the book it draws on.