File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -159,9 +159,27 @@ class ValidationOutput extends HTMLElement {
159159 return ;
160160 }
161161
162- // We don't remove the error message, we just remove the `has-error` state.
162+ // We don't remove the error message if there is a transition, we just remove the `has-error` state.
163+ // It will trigger the transition, and after the transition, the error message will be removed.
163164 // This makes it easier to style and animate the error message.
165+ if ( ! this . #internals. states . has ( "has-error" ) ) return ;
166+
167+ const transitionDuration = parseFloat (
168+ getComputedStyle ( this ) . transitionDuration ,
169+ ) ;
164170 this . #internals. states . delete ( "has-error" ) ;
171+ if ( transitionDuration === 0 ) {
172+ this . innerHTML = "" ;
173+ return ;
174+ }
175+
176+ const handleTransitionEnd = ( ) => {
177+ if ( this . matches ( ":user-invalid" ) ) return ;
178+ this . innerHTML = "" ;
179+ } ;
180+ this . addEventListener ( "transitionend" , handleTransitionEnd , {
181+ once : true ,
182+ } ) ;
165183 }
166184
167185 #setErrorMessage( message : string | DocumentFragment ) {
You can’t perform that action at this time.
0 commit comments