The left side of the form input material is obscured unless the necessary criteria are fulfilled

I am currently in the process of developing the front-end for a web application using the material library. The issue I am facing is that when a field does not meet its requirements, such as needing to enter a 'bedrijfsnaam', the border turns red but the left side of the border disappears. Despite trying various solutions, I am unable to find the right approach to fix this.

When the border has no color, it should be solid all around like this: https://i.stack.imgur.com/JO2zy.png

If an error occurs and 'Bedrijfsnaam' is not filled in, the border looks like this: https://i.stack.imgur.com/RZDha.png

As you can see, the left side gets cut off... I want the border to continue seamlessly

Here is the HTML code snippet:

import { CommonModule } from '@angular/common';
import { Component, inject } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MatInputModule } from '@angular/material/input';
import { MatFormFieldModule } from '@angular/material/form-field';

@Component({
  selector: 'subscription-form',
  standalone: true,
  imports: [
    MatFormFieldModule,
    MatInputModule,
    CommonModule,
    FormsModule,
  ],
  styleUrls: ['./subscription-form.component.scss'],
  templateUrl: './subscription-form.component.html',
})
export default class SubscriptionFormComponent {
}
.subscriptionForm {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(2, 1fr);
  justify-items: center;
  align-items: start;
}
<form class="subscriptionForm" #form="ngForm"">
  <div class="textFields">
    <mat-form-field appearance="outline">
      <mat-label>Naam</mat-label>
      <input matInput type="text" name="name" />
    </mat-form-field>
    <mat-form-field appearance="outline">
      <mat-label>Bedrijfsnaam</mat-label>
      <input matInput type="text" name="companyName" required />
</form>
</mat-form-field>

Answer №1

After spending countless hours trying to figure it out, I finally came up with a solution that worked:

    ::ng-deep .mdc-text-field--invalid .mdc-notched-outline .mdc-notched-outline__leading {
      border-left-color: red !important;
      border-right-color: transparent !important;
      border-style: solid !important;
      border-top-left-radius: 4px !important;
      border-bottom-left-radius: 4px !important;
      margin-right: -3px;
    }

If you have any suggestions on how to improve this code, please feel free to share!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can the Okta clientId be securely shared in a public repository?

Setting up Okta authentication in an Angular application involves adding a configuration variable with the necessary settings for your OIDC app in the app.module.ts file. You can find more information here. const config = { issuer: 'https://dev-1 ...

What could be the reason for the malfunctioning dropdown menu in my navigation bar upon clicking it?

After spending hours practicing creating a navbar using Bootstrap 3.3.7, I've hit a roadblock - the dropdown is not working when clicked on. It's frustrating because I have double-checked all my scripts and ensured that I have the latest version ...

Add text to the forefront of video content while in fullscreen mode

Currently, I am facing an issue while trying to embed a video from YouTube. I am unable to draw anything (text, image, etc.) when the video is in fullscreen mode. Despite my attempts to use z-index, it has not been successful. My goal is to create a n ...

Angular Checkbox Click EventLearn how to handle click events on

How can I toggle the visibility of a form using ngIf when a click event is triggered by a checkbox? Below is the code for my column header and column values: <th><label class="btn btn-filter"> <input type="checkbox" ...

Problems Arising with Javascript Animation Functionality

I've created a script for an interactive "reel" that moves up or down when clicking on specific arrow buttons. However, I'm encountering two issues: 1) The up arrow causes it to move downward, while the down arrow moves it upward. 2) After exe ...

Is there a way to display the text that has been selected?

I would like to display the text of a clicked link in an empty div element. Can someone help me achieve this? Thank you. <div></div> <span>link one</span> <span>link two</span> <span>link three</span> ...

The vertical tabs in JQueryUI lost their functionality when a few seemingly unrelated CSS styles were added

Check out the JsFiddle demo here I embarked on a mission to craft JQueryUI Vertical tabs by following the guidance provided in this example. The source code within the aforementioned link contains specific CSS styles: .ui-tabs-vertical { width: 55em; } ...

Trigger an event when an Angular template's *ngIf condition is met

Let's say I am using the Angular directive *ngIf to display a user object like so: <div *ngIf="user$ | async as user" class="container"> <p>{{user.name}}</p> </div> Is there a method where I can trigger some code once this ...

Measuring the height of an element within its parent component using Angular 4

Check out my demo here I've created a basic parent component along with a child component. Is there a way to retrieve the height of the parent div from within the child component? import { Component, Input, ElementRef, OnInit, ViewChild } from &apo ...

Changing the size of the Modal Panel in Ui Bootstrap for a customized look

Currently, I am in the process of developing an application that utilizes Ui bootstrap to seamlessly integrate various Bootstrap components with AngularJs. One of the key features I require is a modal panel, however, I found that the default size option &a ...

Could a javascript loop be created to continuously activate a button with each iteration?

I have just started learning javascript and I am in the process of creating a website where users can change the background by simply clicking on a button. It's working perfectly fine so far, but I want to add another feature where the background imag ...

Utilize Angular to Transfer HTTP Array Data from a Service to a Component

As I work on developing an app with Angular, my current challenge involves a service that retrieves an Array of Data from an online source. My goal is to make this array accessible in other components but I'm facing difficulty in passing the data to t ...

Checking if children have certain text using jQuery

My task involves filtering an HTML table. In order to accomplish this, I have created an 'each' callback for all 'tr' elements and check if any of their children contain a specific pattern. $("#filter").keypress(function() { var fi ...

Do changes in Input fields reflect in the parent component?

I was under the impression that I could share data with child components using @Input() directive and communicate data back to the parent component with @Output() along with the appropriate emit. However, I recently discovered that modifications made to th ...

When the JSON array is converted into a string, it appears as undefined

Below is a snippet of my service.spec.ts file: service.spec.ts it('should mock the http requests', inject([Service, MockBackend], (service, mockBackend) => { let result:any; mockBackend.connections.subscribe((connection) => { ...

Achieving effective targeting of the second segment within a string enclosed in a span tag through increased specificity

When it comes to styling elements, the easiest way is to use classes and assign the properties needed. However, 1. I'm not a huge fan of creating classes all over the place. That's what specificity and CSS mapping are for. 2. Going thro ...

Excessive screen height causes the CSS box layout to overflow

I am looking to create a screen layout similar to the one shown in this image. It should consist of a row with no overflow and include: A left box that contains: A fixed height header (20px), An aspect square box taking up the remaining height. ...

How can I make all fields in the CKAN Resource form html the same size as the "Description" field?

I am completely new to CKAN and front-end development. I've been scouring through various html/css files without success in locating where I can adjust the field sizes in the resources form (where users can modify metadata via GUI). I would like to r ...

Optimal Strategies for Handling CORS in Angular 2+ and Node/Express Servers

Currently, I am in the process of implementing user authentication with Express/Node and testing cookies from an Angular frontend. Upon logging in, the cookies are properly displayed in the network tab but not in the application tab. I understand that usi ...

Encountering error "module fibers/future not found" while creating a meteor method in typescript

While working on a Meteor method for async function in my project that combines Meteor with Angular2 using Typescript ES6, I encountered an error. The issue is related to a sync problem in the insert query when inserting data with the same name. To resolve ...