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

feat(form-core): add a way to prevent registration of a form-element #2247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gerjanvangeest
Copy link
Member

What I did

Copy link

changeset-bot bot commented Apr 9, 2024

🦋 Changeset detected

Latest commit: caa01e4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@lion/ui Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@tlouisse
Copy link
Member

tlouisse commented Apr 9, 2024

Ideally the developer using composition inside a FormControl should not be bothered with this.
I think we can do it in such a way that we align this behavior with how modelValues are propagated (LionInputTelDropdown is already considered an "endpoint". (Fields are endpoints, FormGroups aren't))

Screenshot 2024-04-09 at 12 10 05

Fields have this._repropagationRole = 'child'. How this is currently handled for the modelValue repropagation: https://github.com/ing-bank/lion/blob/master/packages/ui/components/input-tel-dropdown/src/LionInputTelDropdown.js#L445

We should solve both (modelValue repropagation and registration)in a more generic way.
Maybe we can do:

In FormControlMixin:

/**
 * Whether 
 * @readonly
 */
get _isEndPoint() {
  return this.__isEndpoint || (this._repropagationRole === 'child');
}
  
/**
 * We should only repropagate modelValue events if we are a group (not if we are an endpoint without children)
 */
_repropagationCondition() {
  return !this._isEndpoint;
}

In FormRegistrarMixin:

// prevent child registration if _isEndpoint

N.B. above is pseude code and there will be a few edge cases we need to tackle as well.
(edge cases will mainly be the situations with options (child) registering to choice-group.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants