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

Remove data-error attribute when removing errors #241

Closed
wants to merge 2 commits into from
Closed

Remove data-error attribute when removing errors #241

wants to merge 2 commits into from

Conversation

MaximBalaganskiy
Copy link
Collaborator

Currently, the attribute is not cleared which later overrides a different error message

Currently, the attribute is not cleared which later overrides a different error message
@coveralls
Copy link

Coverage Status

Coverage remained the same at 95.154% when pulling f31a027 on MaximBalaganskiy:master into c75d8d4 on aurelia-ui-toolkits:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 95.154% when pulling 05e22d1 on MaximBalaganskiy:master into c75d8d4 on aurelia-ui-toolkits:master.

@Ullfis
Copy link
Contributor

Ullfis commented Aug 30, 2016

Nice one 😄

The data-error value is set by md-validate-error attribute. If you remove the data-error value, that message is gone.

Brain fart: add temporary data attribute to indicate if data-error is set in code:

      add(element, error) { ..

        // get error message from label
        let msg = label.getAttribute('data-error');
        if(!msg) {
          // error message not set? add
          label.setAttribute('data-error', errorMessage);
          label.setAttribute('data-amb-tmp', 'err');        // ← temporary
        } else {
          // set label message into error object
          error.message = msg;
        }
..
    remove(element, error) { ..

      let label = element.querySelector('label');
      if (label && label.getAttribute('data-amb-tmp')) {
        label.removeAttribute('data-error');
        label.removeAttribute('data-amb-tmp');
      } 

@MaximBalaganskiy
Copy link
Collaborator Author

MaximBalaganskiy commented Aug 30, 2016

Yeah... The question is should you really mix original validation with aurelia validation?.. I also don't particularly like that empty invalid controls stay active. It seems like a materialize CSS bug where validation label is messed up without an active class. I used to have a quick CSS hack in my project to fix that...

@Ullfis
Copy link
Contributor

Ullfis commented Aug 30, 2016

Agree. Original validation should not be used when using aurelia validation. Remove md-validate="true" and use this css:

    label[data-error]:after {
        -webkit-transition-property: all !important;
        transition-property: all !important;
        white-space: nowrap;
        font-size: 0.8rem;
        -webkit-transform: translateY(0);
        -ms-transform: translateY(0);
        transform: translateY(0);
    }

    label[data-error]:not(.active):after {
      -webkit-transform: translateY(-140%);
      -ms-transform: translateY(-140%);
      transform: translateY(-140%);
    }

The error message do a little «bump» when the control get/loose focus. I would really like to know how to fix that.

@MaximBalaganskiy
Copy link
Collaborator Author

@Ullfis i don't think it's possible without removing the transitions

@MaximBalaganskiy
Copy link
Collaborator Author

MaximBalaganskiy commented Aug 31, 2016

I ended up with

.input-field label[data-error]:after {
  font-size: 0.8rem !important;
  white-space: nowrap; }

.input-field label[data-error]:not(.active):after {
  -webkit-transform: translateY(-140%);
  -ms-transform: translateY(-140%);
  transform: translateY(-140%); }

Seems to do the job

@Ullfis Ullfis mentioned this pull request Aug 31, 2016
@Thanood
Copy link
Collaborator

Thanood commented Aug 31, 2016

Should be covered by #245, right? Sorry I've lost track somehow.
If so, I'd like to close this one.

@MaximBalaganskiy
Copy link
Collaborator Author

Seems like this one is a duplicate

On 1 Sep 2016 3:44 AM, "Daniel Bendel" notifications@github.com wrote:

Should be covered by #245
#245,
right? Sorry I've lost track somehow.
If so, I'd like to close this one.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#241 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADimvBNmyCsWOL6SfF7esDkCyx20BnWFks5qlb1zgaJpZM4JwJ-6
.

@Thanood Thanood closed this Aug 31, 2016
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.

4 participants