Skip to content

[OP-20892] Signal inputs from plain attributes: OpPrincipalComponent - #27440

Draft
myabc wants to merge 6 commits into
devfrom
code-maintenance/op-20892-principal-signal-inputs
Draft

myabc wants to merge 6 commits into
devfrom
code-maintenance/op-20892-principal-signal-inputs

Conversation

@myabc

@myabc myabc commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Ticket

https://community.openproject.org/wp/OP-20892

What are you trying to accomplish?

tl;dr for humans: User avatars rendered by the server now update in place when the page is refreshed by Turbo, for example after unassigning someone in the split view, without a special-case workaround.

First wave of OP-19550: opce-principal takes its inputs as signal inputs set from plain attributes instead of JSON in data-* read by populateInputsFromDataset. It also adds the shared pieces the next waves reuse. Fixes the AGILE-462 case on dev; a backport to release/18.0 is offered as an alternative to the workaround in #27341.

Hints for dev review

  • Start with custom_element_tag (app/helpers/custom_element_helper.rb), attribute-inputs.ts, then the morph refresh in openproject-custom-element.ts.
  • <opce-principal> now renders e.g. principal='{"href":…}' hide-name link="false" hover-card-url="…".

What approach did you choose and why?

  • populateInputsFromDataset writes parsed JSON straight onto component fields through Angular's private declaredInputs. That cannot work with signal inputs, and Turbo morphs could not refresh these elements.
  • Angular Elements already maps each observed attribute to setInput, so each signal input gets a transform (booleanAttributeOr, jsonAttribute, …) that turns the attribute string, or null on removal, into the typed value or the input's default.
  • custom_element_tag.<name> mirrors Rails' tag.<name> but dasherizes keys and serializes values: true → bare attribute, false → "false" (several inputs default to true), nil → omitted, arrays/hashes → JSON.
  • Elements registered with { attributeInputs: true } get their observed attributes copied on turbo:before-morph-element instead of being morphed, because a morph would replace the children Angular renders into light DOM. Other opce-* elements keep today's behaviour (neither morphed nor removed), and elements Angular hasn't upgraded yet morph normally. An explicit marker is needed because Angular Elements lists decorator inputs in observedAttributes too.
  • Rails callers that omit link: get link="false", matching the old rendering (the Angular input defaults to true for template callers).
  • title became nameTitle (name-title) to avoid the native title attribute.

AI involvement

Directed – I specified the requirements and AI implemented most of it; I validated via testing rather than a full line-by-line review.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

Adds a helper that renders custom elements with plain attributes.
Rails tag does not dasherize underscore keys and flattens hash values,
so Angular custom elements need a dedicated serializer for inputs.

https://community.openproject.org/wp/OP-20892
Adds transform factories that turn attribute strings, or null when an
attribute is removed, into typed signal input values. Custom elements
receive plain attributes from Rails, so inputs need defaults for
removed attributes and bare-attribute booleans.

https://community.openproject.org/wp/OP-20892
Marks custom elements registered with attribute inputs and copies
their observed attributes from the incoming element during Turbo
morphs, so signal inputs update. Removing a marked element is no
longer prevented, and elements not yet upgraded are morphed so they
read the new attributes. Other opce-* elements keep the no-morph
behavior.

https://community.openproject.org/wp/OP-20892
@github-actions github-actions Bot added the ai: Directed 🪄 A human specified the requirements and AI implemented most of it; They validated via testing. label Nov 28, 2026
Converts OpPrincipalComponent to signal inputs that parse plain
attributes, and has the avatar helper render opce-principal with
custom_element_tag instead of JSON data-* attributes. The element no
longer depends on the one-shot populateInputsFromDataset, so avatars
re-render when Turbo morphs change their attributes. The title input
and option become nameTitle and name-title.

https://community.openproject.org/wp/OP-20892
Adds split view scenarios that unassign and change the assignee of a
backlog work package and check the card avatar updates without a
reload, guarding the AGILE-462 morph regression.

https://community.openproject.org/wp/OP-20892
Adds the frozen string literal magic comment and drops an empty
comment line flagged by RuboCop in files touched on this branch.
@myabc
myabc force-pushed the code-maintenance/op-20892-principal-signal-inputs branch from a85841f to d6570e6 Compare November 28, 2026 01:34
return;
}

// Turbo dispatches this event without newElement when removing a node, although its types say otherwise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs checking

@myabc
myabc requested a review from dombesz November 28, 2026 01:38
@myabc myabc added ruby Pull requests that update Ruby code javascript Pull requests that update Javascript code labels Nov 28, 2026
@myabc myabc changed the title [OP-20892] Signal inputs from plain attributes: OpPrincipalComponent [OP-20892] Signal inputs from plain attributes: OpPrincipalComponent Nov 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai: Directed 🪄 A human specified the requirements and AI implemented most of it; They validated via testing. javascript Pull requests that update Javascript code ruby Pull requests that update Ruby code

Development

Successfully merging this pull request may close these issues.

1 participant