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

Auto-hide non-multivalued reference widget input on value selection #2363

Merged
merged 6 commits into from
Aug 22, 2023

Conversation

xispa
Copy link
Member

@xispa xispa commented Aug 22, 2023

Description of the issue/feature this PR addresses

This Pull Request improves the styling of the Reference widget and hides the select input text when there is a value selected and the reference widget is not multiValued (the hide_input_after_select attribute is no longer necessary).

Current behavior before PR

Sample add form:

Captura de 2023-08-22 20-06-15

Sample view form:

Captura de 2023-08-22 20-07-38

Desired behavior after PR is merged

Sample add form

Captura de 2023-08-22 20-04-35

Sample view form

Captura de 2023-08-22 20-08-46

--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.

@xispa xispa requested a review from ramonski August 22, 2023 18:28
@@ -112,8 +111,6 @@ def get_input_widget_attributes(self, context, field, value):
"data-multi_valued": getattr(self, "multi_valued", True),
"data-disabled": getattr(self, "disabled", False),
"data-readonly": getattr(self, "readonly", False),
"data-hide_input_after_select": getattr(
self, "hide_input_after_select", True),
Copy link
Contributor

Choose a reason for hiding this comment

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

Please also remove the attribute from the DX version:

"data-hide_input_after_select": getattr(
self, "hide_input_after_select", True),

Copy link
Member Author

Choose a reason for hiding this comment

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

Done with b5ed67f

form[name=analysisrequest_add_form] {
.field {
margin-bottom: 0;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why this is here inside. Also I do not see any DOM elements in the add form with a class="field" at the moment.

Copy link
Member Author

Choose a reason for hiding this comment

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

See this:

Captura de 2023-08-22 22-11-02

@@ -76,7 +76,7 @@ class SelectedValues extends React.Component {
<button value={value}
data-toggle="confirmation"
data-title={_t("Unlink reference?")}
className="btn btn-sm btn-link-danger"
className="btn btn-sm p-0 ml-2"
Copy link
Contributor

Choose a reason for hiding this comment

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

This one is cool. Makes the whole item smaller. Thanks for this one.

if (this.state.readonly) {
return false;
}
if (!this.state.multi_valued && this.state.values.length > 0) {
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure about this. Probably the last line needs to be first to keep the input widget visible, even if it is readonly/disabled.
Or maybe just return True if this.state.multi_valued?

Copy link
Member Author

Choose a reason for hiding this comment

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

Why one would want the input element to be displayed if it cannot be used (because is disabled or readonly)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, good point. To see that it is disabled by purpose maybe?

@xispa xispa changed the title Reference widget styling Auto-hide non-multivalued reference widget input on value selection Aug 22, 2023
@ramonski ramonski merged commit 9e6b672 into 2.x Aug 22, 2023
2 checks passed
@ramonski ramonski deleted the reference-widget-button-styling branch August 22, 2023 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants