Skip to content

hideUserInputOnNoneTextInput with checkboxes failure #175

@nuFaqtz

Description

@nuFaqtz

Hi Felix,

I'm having the same trouble as #165 with a checkbox group.
If you change the code for:

if (cf.UserInputElement.hideUserInputOnNoneTextInput) {
   ...

to

if (cf.UserInputElement.hideUserInputOnNoneTextInput) {
	// toggle userinput hide
	if (this.controlElements.active) {
		// But only if it does not interfere with the flow, i.e. with a file control and/or checkboxes
		var isFlowRequired = this._currentTag.type === "file" || (this._currentTag.elements && this._currentTag.elements[0].type === "checkbox");
		if (isFlowRequired) {
			this.el.querySelector("cf-input-button").classList.add("isFlowRequired");
		}
		this.el.classList.add("hide-input");

		// set focus on first control element (when not prevented)
		if (!cf.UserInputElement.preventAutoFocus) {
			this.controlElements.focusFrom("bottom");
		}
	}
	else {
		this.el.classList.remove("hide-input");
		this.el.querySelector("cf-input-button").classList.remove("isFlowRequired");
	}
}

and modify the css for the cf-input-button to:

cf-input.hide-input input,
cf-input.hide-input textarea {
    /* We need it to take space for the button to stay on its own line*/
    visibility: hidden;
}

cf-input.hide-input cf-input-button:not(.isFlowRequired) {
    display: none;
}

Then in those cases you're left with only the button on the right, which works well (enough).
One could argue that maybe centring the button (with label) would be even better, but for now this works.

Edit
Have to figure something out for the error messages in these cases. Working on something generic, independent from the input.
Will let you know when and what I have something that works.
Edit

P.S. I noticed that the first item is auto selected when the input is hidden, but that should not be the case when the user has prevented auto focus.

mzZzl,
JamBo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions