Topic: SCSS with different behavior between versions
allancmello
premium
asked 2 weeks ago
Expected hover not to change to components.
Hover being displayed outside of MDB/Angular standard
The code was thoroughly inspected, and the only difference is in the SCSS declaration that changed, I even followed the solution indicated by MDB support. Here -> https://mdbootstrap.com/support/angular/mdb-uses-the-legacy-import-syntax-in-angular-19-instead-use-syntax/
Arkadiusz Idzikowski
staff
answered 4 days ago
To remove or customize the hover background color of the outline warning button, you can override the value of the --mdb-btn-hover-bg
variable:
.btn-outline-warning {
--mdb-btn-hover-bg: transparent;
}
If you need to do that only for a single buttom, just add some custom class to this component and adjust the CSS rule:
.your-custom-btn-class {
--mdb-btn-hover-bg: transparent;
}
If you need to customize colors in your app and add the ability to dynamically switch between different versions (for example between light/dark/custom theme) you may want to read about the new color modes introduced in v8: https://mdbootstrap.com/docs/angular/content-styles/theme/
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Premium
- Premium support: Yes
- Technology: MDB Angular
- MDB Version: MDB5 8.0.0
- Device: All
- Browser: All
- OS: All
- Provided sample code: No
- Provided link: Yes
Arkadiusz Idzikowski staff commented 2 weeks ago
The changes you made in
angular.json
should not affect the styles in any way. These settings are only used to silence the warnings with information about the import syntax deprecation.Do you use exactly the same syntax in both versions of the app? The import syntax is now marked as deprecated but it is still valid and you should use it to add MDB styles.
There must be a difference in the styles of those two buttons when you inspect both elements in the browser dev tools. Could you please check that and provide some more information about the problem?
allancmello premium commented 1 week ago
Hi Arkadiusz,
Nothing was changed in the migration, what was changed was the use of MDB version 8.
Only the outline buttons are problematic hover color, the other button options are normal.
Code Html:
SCSS code the button from console DevTools:
}
allancmello premium commented 1 week ago
Arkadiusz, my last test.
I run one last test to check if the problem is with Angular, as in version 18 with mdb5, hover works without problems.
I deleted node-modules and packge-lock.json, copied all the code without changing anything to a new directory, changed packge.json from version 7.1 to v8 with the same version of Angular 18.
I cleared the npm cache and reinstalled the modules with npm i, and the same problem appeared. In other words, the problem is in mdb-angular-ui-kit-8.
In version mdb-angular-ui-kit-7.1, regardless of the Angular version, hovering for outline buttons works perfectly.
allancmello premium commented 1 week ago
Hi Arkaduisz,
This is a test with the new version of mdb-angular-ui-kit-9, with a clean app, an minimum example of MDB5 itself. And the problem persists, that said, the problem is in MDB5 and not in my project.
Follow the screens to help you understand better.
It's frustrating when things don't work out. It's laborious and costly to waste hours investigating "simple" problems that shouldn't exist. I don't feel comfortable migrating from version 7.1 to version 9, as I haven't even managed to complete the migration to version 8. Anyway, I await your feedback.
allancmello premium commented 1 week ago
After many hours of late-night research, I discovered the cause of the bugs.
In Angular 20 with Zoneless (and not zone.js), the components don't behave as they should.Components that depend on the "BrowserAnimations" module in NgModules mode and "provideAnimations" in Standalone mode exhibit some kind of unexpected behavior.
In both modes (Standalone/NgModules), the use of animations conceptually in previous versions is deprecated, so components with MDB5 animations, such as the Tooltip and buttons (btn-outline), don't work.
However, in an Angular 20 app using zone.js, even though they're marked as deprecated, the components "work," despite anomalies, such as the "btn-outline" button.
Remember when you asked me if this only happens in Standalone mode?
It happens in both modes, but with different behaviors due to the declaration of the "Animations" module and whether or not Zoneless is used.
Arkadiusz, I hope this can help you find a solution for using MDB5 with Zoneless and the deprecated animation mode in Angular 17 above.
allancmello premium commented 1 week ago
Arkadiusz,
Exactly that!
When removing "provideZonelessChangeDetection()" and using zone.js (import zone.js) the "Tooltip" component started working again, but the "btn-outline" button still has the "hover" anomaly when hovering over it.
I hope I helped.
Arkadiusz Idzikowski staff commented 1 week ago
In case of any problems with Angular change detection we recommend to try to use the change detection with Zone.js as some MDB components may still rely on the updates provided by this library to update the component state. The same goes for the
provideAnimations
orBrowserAnimationsModule
. These modules are deprecated now but they are still available in Angular v20.As for the button animation issues, I think they are directly related to styles and no other settings should matter here, because this component does not use any JavaScript code.
If I understand correctly, you are using some custom styles, because the button visible in the attached image looks slightly different than the default MDB oultine button (please correct me if I'm wrong). Perhaps due to minor style changes in newer MDB versions, your custom styles don't work the same as in version 7.
In this case please try to: 1. Create a new Angular application and configure MDB Angular library 2. Add a default MDB oultine button without any modifications 3. Try to gradually add your own custom styles related to changing the button's appearance
allancmello premium commented 5 days ago
Hey Arcadiusz,
Did you see the example I sent you of MDB 5 itself? It's the pure example that comes without any of my custom CSS.Therefore, the hover issue with the outline button is in the component's CSS.I did exactly what you asked two days ago, using a clean example from mdb-angular-ui-kit-9.
Search here and above for the message from two days ago containing:
"This is a test with the new version of mdb-angular-ui-kit-9, with a clean app, an minimum example of MDB5 itself. And the problem persists, that said, the problem is in MDB5 and not in my project."
Arkadiusz Idzikowski staff commented 4 days ago
I saw the examples you linked earlier, but based on the screenshot from version 7, I compared components in different versions using a light background, which made the problem less visible.
You're right, I apologize for the confusion. This problem is caused by a change in the MDB styles we introduced in version 8 to adapt the components to the new theming system. Since this version, outline buttons have an additional style on the hover that adds a light background.
To fix this problem while using a custom colored background in v8 or v9, you would need to either remove the additional background color on the button or adjust it to your needs. Please see my answer to learn how to easily override this value.