AllenFang / react-bootstrap-table

A Bootstrap table built with React.js
https://allenfang.github.io/react-bootstrap-table/
MIT License
2.24k stars 783 forks source link

Validator message not aligned with the cell #2082

Closed omeraha closed 5 years ago

omeraha commented 5 years ago

Hi,

I wrote a cell validator according to this example (following is a shorter version of the original code):

{
    text: 'IPv4', 
    dataField: 'IPv4',
    validator: (newValue, row, column) => {
        if (!isValidIP(newValue)) {
            return {
                valid: false,
                message: 'Must be a valid IP address'
            };
        }
        return true;
    }
};

The logic works well, but for some reason the error message isn't aligned with the field and doesn't fully appear: image

Update:

I inspected the html, and saw that when the validation method returns, the following component is added to the html file:

<div class="alert alert-danger in" role="alert">
    <strong>Must be a valid IP address</strong>
</div>

When I removed the 'alert' property from the class, the message appeared properly:

<div class="alert-danger in" role="alert">
    <strong>Must be a valid IP address</strong>
</div>

image Am I doing something wrong here? Can I somehow remove the 'alert' attribute from the returned component?

omeraha commented 5 years ago

Found the problem. The misalignment were due to the following css configurations:

.alert {
  left: -50%;
  z-index: 100;
}