Closed Bug 1689317 Opened 4 years ago Closed 4 years ago

SAP - Paste event doesn't work for web components

Categories

(Core :: DOM: Events, defect)

Firefox 84
defect

Tracking

()

RESOLVED FIXED
87 Branch
Tracking Status
firefox87 --- fixed

People

(Reporter: martin.georgiev, Assigned: emilio)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36

Steps to reproduce:

Open the following example.
https://codesandbox.io/s/ui5-webcomponents-forked-gdqfh?file=/src/index.js

  1. Copy some text
  2. Paste it in the input from the example

Actual results:

The paste event is not fired, which is most probably some bubbling issue. This works in other browsers.

Expected results:

The paste event should be fired.

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → DOM: Events
Product: Firefox → Core
Summary: Paste event doesn't work for web components → SAP - Paste event doesn't work for web components

Seems the paste event is composed in other browsers... What does the spec say?

Blocks: shadowdom

AFAICT the clipboard spec does not say anything about shadow tree.

nsCopySupport::FireClipboardEvent properly calls EventDispatcher::Dispatch (and thus the internal element properly gets the event) so it's indeed something about bubbling. The spec says:

  1. If parent is a Window object, or parent is a node and target’s root is a shadow-including inclusive ancestor of parent, then:
    1. If isActivationEvent is true, event’s bubbles attribute is true, activationTarget is null, and parent has activation behavior, then set activationTarget to parent.
    2. Append to an event path with event, parent, null, relatedTarget, touchTargets, and slot-in-closed-tree.

It seems it should bubble to the host if I'm understanding it correctly.

This is only about whether the event is composed. The event is composed in chrome / safari, so we should be able to fix it like the patch I just attached, but it'd be nice to have some sort of spec reference?

Oh, TIL .composed 😅

Yes, the spec says it should be composed.

The paste event bubbles, is cancelable, and is composed.

... which also applies to copy and cut events.

I think bug 1620420 reported this problem before.

Assignee: nobody → emilio
Attachment #9199965 - Attachment description: Bug 1689317 - Clipboard events should be composed. → Bug 1689317 - Clipboard events should be composed. r=smaug,edgar
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d5eeffaaf436 Clipboard events should be composed. r=smaug
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/27387 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: