Tips on how to eliminate focus after choosing a radio button in Angular Material?

This is a snippet from my HTML template file, which includes two Angular Material radio buttons. My goal is to disable the focus on the rings quickly after selecting any radio button.

<div id="login-form" class="vh-100 overflow-auto">
    <div>
        <mat-horizontal-stepper [@.disabled]="true" labelPosition="bottom" [linear]="true" #stepper>
            <mat-step>
                <div>
                    <div class="header">
                        <div class="">
                            <span>Login to your Account </span>
                        </div>
                    </div>

                    <mat-divider></mat-divider>

                    <div id="content" class="p-0">
                        <div>
                            <legend class="Input-legend">Login Using</legend>
                            <mat-radio-group aria-label="Select an option" class="radio-btn-container">
                                <mat-radio-button class="my-2" value="1"
                                    checked="true"><span>Mobile</span></mat-radio-button>
                                <mat-radio-button class="my-1" value="2"><span>
                                        number</span></mat-radio-button>
                            </mat-radio-group>

                            <mat-divider class="mat-div1"></mat-divider>


                            <div class="continue-btn-holder">
                                <div class="temp"></div>
                                <button class="continue-btn">Continue</button>
                            </div>

                            <mat-divider class="mat-div2"></mat-divider>
                          </div>
                    </div>
                </div>
            </mat-step>
        </mat-horizontal-stepper>

    </div>
</div>

This is a portion of my CSS file

/* CSS code for radio buttons */
::ng-deep
  .mat-radio-button.mat-accent.mat-radio-checked
  .mat-radio-outer-circle {
  border-color: #379aaf !important;
}

/* Other CSS styles */

Ts file does not have any specific code

I am looking for a solution where the outer circle's focus gets disabled quickly after selecting any radio button. I have done some research but haven't found a suitable solution yet.

Answer №1

When it comes to the focus event, CSS alone cannot change the focus. To achieve this, Javascript must be used, as demonstrated in the following template:

<mat-radio-group 
     aria-label="Select an option" 
     class="radio-btn-container"
     #radios
     (change)=radios.blur()>
  ...
</mat-radio-group>

Additionally, setting a template variable for the "Continue" button and calling focus on it might be helpful. Here's how you can do that:

<mat-radio-group (change)=button.focus()>...</mat-radio-group>
<button #button>Continue></button>

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

How can you generate a branch line for the sub menu using Material UI and React?

https://i.sstatic.net/OeUg6.jpg Greetings! As a newcomer to MUI and React, I am curious if there is a method to create a "branch line" for the sub menu. The attached photo illustrates how the Settings section displays branch lines leading into the child s ...

Steps icons in the MUI Stepper component can be adjusted to remove the space between line connectors

I'm running into an issue while attempting to build a Stepper component using MUI V5. The problem I am facing is the presence of a gap between the icons and the line connectors. Here's what my current setup looks like: https://i.sstatic.net/UoMs ...

Previewing the small version, loading the URL into a container

Currently, I am working with jQuery's .load(url, ...) function to bring in a url and display it within a div. However, I am facing an issue where the result needs to be resized in order to fit correctly within the layout. Can anyone provide guidance o ...

Issue with the MUI Autocomplete display in my form

Recently, I started using Material UI and Tailwind CSS for my project. However, I encountered an issue with the Autocomplete component where the input overlaps with the following DatePicker when there is multiple data in the Autocomplete. I have attached a ...

What is the best way to generate a table with continuously updating content?

If the user input : $sgl = 2; $dbl = 0; $twn = 1; $trp = 0; $quad = 0; $price_room = 250000; I want the result looks like the picture below : https://i.sstatic.net/iQYqr.jpg I have tried the following code : <?php $sgl = 2; $dbl = 0; ...

Having trouble with the upgrade process from Angular 4 to Angular 6

I am currently in the process of upgrading my project from angular version 4 to 6. The steps outlined in this URL have been very helpful: https://update.angular.io/ While attempting to update my Angular packages using the command ng update --all --next -- ...

Functionalities of HTML controls

I currently have a select element in my HTML code which looks like this: <select> <option id="US" value="US"> </option> <option id="Canada" value="Canada"> </option> </select> My requirements are twofold: ...

inject custom styles into a Material-UI styled component

Although I have come across similar questions, none seem to directly address my current situation. I am in the process of transitioning from MUI v4 to MUI v5 and have encountered various scenarios where a specific style is applied externally. For instance ...

Z-index problem occurring with rotateY on Safari and Chrome Mobile

https://jsfiddle.net/nxbg7rq3/ I've been struggling to get the .mask completely on top of the .screen in this example. It works fine in most browsers, but Safari and Chrome Mobile are giving me a hard time. I've experimented with various solutio ...

To prevent the default alignment in case the text exceeds the input length, stop the automatic alignment

I have a query regarding an input field with a maximum length of 4 characters. The appearance is such that these 4 characters seem to be delineated by borders which are actually 3 lines displayed above the input field. When I enter the fourth character, a ...

Selectize-dropdown menu shines brightly as it opens upwards

In my sleek dashboard design, I have implemented a few dropdown menus using selectizeInput. These menus are currently positioned at the bottom of the page, but I want them to open in an upward direction instead of downward. While I found a workaround for ...

Tips for utilizing Material UI's Tooltip feature alongside a TableRow

I'm currently facing an issue where I'm trying to include a MUI TableRow inside a Tooltip component in order to display a long uuid when hovering over the row. However, I noticed that all the columns of the row are being compressed into the first ...

Discover the secret to halting a CSS animation precisely on the final nth-child in CSS3

I have encountered some difficulty in stopping a crossfade animation on the last nth-child element. Although I am aware of using animation-fill-mode: forwards, implementing it in different places such as in the initial .crossfade declaration did not yield ...

Angular RxJS: The never-ending reduction

I have developed a component that contains two buttons (searchButton, lazyButton). The ngOnDestroy method is defined as follows: public ngOnDestroy() { this.unsubscribe$.next(); this.unsubscribe$.complete(); } I have created two observables from ...

The border of the Material UI Toggle Button is not appearing

There seems to be an issue with the left border not appearing in the toggle bar below that I created using MuiToggleButton. Any idea what could be causing this? Thank you in advance. view image here view image here Just a note: it works correctly in the ...

Having trouble getting the show/hide div feature to work in a fixed position on the

Trying to show/hide a div using jQuery isn't working when the div is wrapped in a position:fixed element. However, changing it to position:relative makes the show/hide function work again. You can see an example of the working version with position:r ...

Discovering the way to retrieve information from a service in Angular post-subscription

This is the service I provide: getDataDetails(id: any) { this.dataDocumment = this.afs.doc('data/' + id); return this.data = this.dataDocumment.valueChanges().subscribe(res =>{ this.data = res; console.log(this.data); ...

Troubleshooting Angular 2 routes failing to function post aot compilation deployment

Currently, I am implementing RouterModule in my project and have the following configuration in my app.module.ts file: const appRoutes: Routes = [ { path: '', redirectTo: 'mainMenu', pathMatch: 'full' }, { path: 'mainMen ...

Why can't Material-UI Textfield accept both type and maxlength simultaneously?

I'm currently working on a project using Material-UI in combination with React and TypeScript. <TextField id='user-id' label='User ID' type='number' required helperText='Required' inputProps={{ m ...

When using Ruby and Rack on Heroku to serve a static site, the CSS styling may not be

Trying to deploy a static site consisting of HTML, CSS, font, and image files with Ruby Rack has been a bit challenging. While the HTML displays perfectly in Chrome when running it locally, the CSS assets do not seem to be loading or being applied to the H ...