Skip to content

Commit

Permalink
Fix validation feedback message positioning (v1.2.2)
Browse files Browse the repository at this point in the history
Import Fragment from React to avoid needing a div as wrapper for the Render
Move the <Alert> as sybling of the div with checkboxes (instead of child) so the Alert ValidationFeedback is actually rendered below the checkboxes instead of next to the checkboxes (when showing vertically)
  • Loading branch information
stephanbruijnis committed Feb 23, 2024
1 parent 702dd11 commit da877e9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
@@ -1,9 +1,9 @@
{
"name": "multiselectenum",
"widgetName": "MultiSelectEnum",
"version": "1.2.1",
"version": "1.2.2",
"description": "Select multiple enumeration values",
"copyright": "2023 Stephan Bruijnis Consultancy",
"copyright": "2024 Stephan Bruijnis Consultancy",
"author": "Stephan Bruijnis",
"engines": {
"node": ">=12"
Expand Down
34 changes: 18 additions & 16 deletions src/MultiSelectEnum.tsx
@@ -1,4 +1,4 @@
import { Component, ReactNode, createElement } from "react";
import { Component, ReactNode, createElement, Fragment } from "react";
import { hot } from "react-hot-loader/root";

import { MultiSelectEnumContainerProps } from "../typings/MultiSelectEnumProps";
Expand Down Expand Up @@ -31,18 +31,20 @@ class MultiSelectEnum extends Component<MultiSelectEnumContainerProps> {
// Current value of the string attribute that contains the comma separate values (enumeration keys)
// const valueStr = this.props.enumAttribute_str.value || "";
// console.debug("enumAttribute_str: " + { valueStr });

// Enable validation feedback on this input element
const validationFeedback = this.props.enumAttribute.validation;
const className = classNames(this.props.className, this.props.orientationMode === "horizontal" ? "checkboxes inline" : "checkboxes");
return (
<div
<Fragment>
<div
className={className}
style={this.props.style}
tabIndex={this.props.tabIndex}>
{this.universe.map((this.eachEnumKey), this)}
<Alert>{validationFeedback}</Alert>
</div>
<Alert>{validationFeedback}</Alert>
</Fragment>
);
}

Expand All @@ -53,10 +55,10 @@ class MultiSelectEnum extends Component<MultiSelectEnumContainerProps> {
// Determine of the current enumeration value (key) is available in the string and thus should be shown as a checked checkbox
var checkedState = valueStr.includes(enumKey);

if (this.renderAsText()){
if(checkedState){
if (this.renderAsText()) {
if (checkedState) {
return (
<CheckboxText
<CheckboxText
key={i}
index={i}
enumKey={enumKey}
Expand All @@ -72,21 +74,21 @@ class MultiSelectEnum extends Component<MultiSelectEnumContainerProps> {
else {
return (
<CheckboxItem
key={i}
index={i}
enumKey={enumKey}
label={this.props.enumAttribute.formatter.format(enumKey)}
checkedState={checkedState}
onUpdate={this.onUpdateHandle}
disabled={this.isReadOnly()}
widgetId={this.props.id}
key={i}
index={i}
enumKey={enumKey}
label={this.props.enumAttribute.formatter.format(enumKey)}
checkedState={checkedState}
onUpdate={this.onUpdateHandle}
disabled={this.isReadOnly()}
widgetId={this.props.id}
/>
);
}
}

private renderAsText(): boolean {
return this.props.enumAttribute.readOnly && this.props.readOnlyStyle=="text";
return this.props.enumAttribute.readOnly && this.props.readOnlyStyle == "text";
}

private isReadOnly(): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/package.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="MultiSelectEnum" version="1.2.1" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="MultiSelectEnum" version="1.2.2" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="MultiSelectEnum.xml"/>
</widgetFiles>
Expand Down

0 comments on commit da877e9

Please sign in to comment.