Skip to content

applets/clipboard: handle null when applet not open

Reason for the change

The clipboard applet's context hides the "Clear History" context menu entry while editing the clipboard. To do this, it needs to access the fullRepresentation's state, but the fullRepresentation is not loaded while the applet (in the panel) is not open, so the access fails as the property is null, causing an unnecessary error to be printed.

This change guards against this by using optional chaining. Returning undefined is fine here, as that evaluates to false, and the user is not editing in a closed popup.

Test plan

Add the clipboard applet to the panel, launch plasmashell from a terminal, verify error message "TypeError: Cannot read property 'clipboardMenu' of null".

Apply MR, launch plasmashell from a terminal, verify absence of error message.

Screenshots or screen recordings

N/A

Bugs fixed

N/A

Merge request reports

Loading