@mocanvas/mocanvas · interface

TLUiLayerNesting

interface TLUiLayerNesting

How a layer learns about the layers opened from inside it.

Every floating layer is portalled to the same place, so a submenu is a *sibling* of the menu that opened it, not a descendant. A dismiss check written as "did the press land inside me?" therefore answers no for a press on the submenu's own rows — and closes the whole menu on pointer-down, before the click that would have chosen the row ever happens. Every submenu item in the chrome was unreachable for exactly this reason.

A layer registers its element with the layer it was opened from (and, up the chain, with that layer's own parent), so "inside me" can mean "inside me or anything I opened".


Methods · 2

containsNested(target: Node): boolean

Whether target is inside a layer opened from this one.

register(node: HTMLElement): () => void

Register a nested layer's element. Returns the un-register.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.