0

I have a child component which has several tabs with the following CSS property:

a {
    padding: 7px 14px;
    display: inline-block;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    &:hover,
    &:focus {
      background-color: pink;
      border-bottom: 2px solid red;
    }
}

When I click on back button it goes back to the previous selected tab which is fine but the focus is not removed from the current one unless I click on any other part of the screen.

How to remove the focus?

Penny Liu
  • 15,447
  • 5
  • 79
  • 98
alia
  • 459
  • 4
  • 16

1 Answers1

0

I think, I have a different solution for that you can set your on navigate back using document and id. Here is a sample code below=>
HTML:

<input id="abc">
<button (click)="mySetDefaultFocus()">Set Focus</button>

TS:

 mySetDefaultFocus(){
     document.getElementById(`abc`).focus();
  }

Note: You can call that method mySetDefaultFocus on navigate change or ngInit.

Srijon Chakraborty
  • 2,007
  • 2
  • 7
  • 20