pixiebrix-extension
pixiebrix-extension copied to clipboard
Warn if brick is in "inherit" mode and selector matches element on page, but otherwise doesn't match
Context
- Element-based triggers (e.g., keyup) pass through the element that triggered the event
- Root-aware bricks (e.g., JQuery) by default evaluate w.r.t. to root element
- Our selector inference in the interface generates global selectors, not w.r.t. the root element
- This leads to confusion from creators as to why no data is being passed through
Discussion
Options:
- In jquery and other bricks using selectors, could warn if selector doesn't match relative to root, but matches globally. Downside: would have to add to each brick using safeFind. Also, would probably only want to warn once per page
- In the Page Editor, we might want to change the default to "document" and then the user can switch to inherit as needed
- We can use the new validation framework to warn if a selector has id or other selector types while in inherit mode