Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextField throws error when used inside web component (and shadow dom) #313

Closed
arjangeertsema opened this issue Dec 3, 2023 · 2 comments · Fixed by #318
Closed

TextField throws error when used inside web component (and shadow dom) #313

arjangeertsema opened this issue Dec 3, 2023 · 2 comments · Fixed by #318
Labels
bug Something isn't working

Comments

@arjangeertsema
Copy link
Contributor

Describe the Bug

TextField (and TextArea) throws error when input changes and the properties panel resides inside a web component.

The scope changes from shadow dom (inside handleInput method instance) to dom (inside handleInputCallback debounce method instance).

Same goes for TextArea.

Checkbox, Select and FEEL editor work as expected.

Steps to Reproduce

Create web component with code inside:

import BaseModeler from 'camunda-bpmn-js/lib/base/Modeler';
import ModelerStyle from "camunda-bpmn-js/dist/assets/base-modeler.css";

const modeler = new BaseModeler({
      container: this.renderRoot.querySelector('#canvas') as HTMLElement,
      propertiesPanel: {
        parent: this.renderRoot.querySelector('#properties') as HTMLElement  
      }
});

await modeler.createDiagram();

And then change the name of the process.

Expected Behavior

Exception: TypeError: Cannot read properties of undefined (reading 'length')

Target here is the web component in the dom instead of the input in the shadow dom.

Inside this method e has the right context and e.target equals the input instance

Environment

  • Host (Browser/Node version), if applicable: Brave 1.60.125 and node v18.17.1
  • macOS Sonoma 14.1.1
  • Library version: 3.13.0
@arjangeertsema arjangeertsema added the bug Something isn't working label Dec 3, 2023
@nikku
Copy link
Member

nikku commented Dec 12, 2023

Thanks for opening this issue.

We'll see when we have the time to reproduce and fix it. Contributions (even a code sandbox or the like) welcome!

@nikku nikku added the backlog Queued in backlog label Dec 12, 2023
@arjangeertsema
Copy link
Contributor Author

@nikku this is by design:

The idea behind shadow tree is to encapsulate internal implementation details of a component.

Let’s say, a click event happens inside a shadow DOM of component. But scripts in the main document have no idea about the shadow DOM internals, especially if the component comes from a 3rd-party library.

So, to keep the details encapsulated, the browser retargets the event.

https://javascript.info/shadow-dom-events

To be shadow dom save event should not be passed to debounce function (because of setTimeout, the browser will retarget the event). A quick fix would be to pass e.target instead.

Shall I create a pull request for this bug?

arjangeertsema added a commit to arjangeertsema/properties-panel that referenced this issue Dec 14, 2023
Passed event.target instead of event as parameter to the debounce method.
@bpmn-io-tasks bpmn-io-tasks bot removed the backlog Queued in backlog label Dec 14, 2023
@fake-join fake-join bot closed this as completed in #318 Dec 18, 2023
fake-join bot pushed a commit that referenced this issue Dec 18, 2023
Passed event.target instead of event as parameter to the debounce method.
nikku pushed a commit that referenced this issue Dec 18, 2023
Passed event.target instead of event as parameter to the debounce method.

Closes #313
nikku added a commit to camunda/camunda-bpmn-js that referenced this issue Dec 20, 2023
Cf. https://github.com/bpmn-io/bpmn-js-properties-panel/blob/main/CHANGELOG.md#570

deps: update to @bpmn-io/properties-panel@3.15.0

  Cf. https://github.com/bpmn-io/properties-panel/blob/main/CHANGELOG.md#3140
  Cf. https://github.com/bpmn-io/properties-panel/blob/main/CHANGELOG.md#3150

feat: capitalize `Camunda Form` ([bpmn-io/bpmn-jsproperties-panel#1005](https://github.com/bpmn-io/bpmn-jsproperties-panel/issues/1005))
feat(feel-editor): improve FEEL popup editor icon ([bpmn-io/properties-panel#310](bpmn-io/properties-panel#310))
feat(feel-editor): add contextual keyword completion in FEEL editor
fix(feel-editor): correct parsing of nested lists
fix(feel-editor): correct parsing of incomplete QuantifiedExpression
fix(feel-editor): only allow legal Name start characters
fix: prevent error inside web component ([bpmn-io/properties-panel#313](bpmn-io/properties-panel#313))
nikku added a commit to camunda/camunda-bpmn-js that referenced this issue Dec 22, 2023
Cf. https://github.com/bpmn-io/bpmn-js-properties-panel/blob/main/CHANGELOG.md#570

deps: update to @bpmn-io/properties-panel@3.15.0

  Cf. https://github.com/bpmn-io/properties-panel/blob/main/CHANGELOG.md#3140
  Cf. https://github.com/bpmn-io/properties-panel/blob/main/CHANGELOG.md#3150

feat: capitalize `Camunda Form` ([bpmn-io/bpmn-jsproperties-panel#1005](https://github.com/bpmn-io/bpmn-jsproperties-panel/issues/1005))
feat(feel-editor): improve FEEL popup editor icon ([bpmn-io/properties-panel#310](bpmn-io/properties-panel#310))
feat(feel-editor): add contextual keyword completion in FEEL editor
fix(feel-editor): correct parsing of nested lists
fix(feel-editor): correct parsing of incomplete QuantifiedExpression
fix(feel-editor): only allow legal Name start characters
fix: prevent error inside web component ([bpmn-io/properties-panel#313](bpmn-io/properties-panel#313))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
2 participants