Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Active class override #292

Open
bruceleedrupal opened this issue Mar 27, 2022 · 1 comment
Open

Active class override #292

bruceleedrupal opened this issue Mar 27, 2022 · 1 comment

Comments

@bruceleedrupal
Copy link

bruceleedrupal commented Mar 27, 2022

if we set attr() method on menu item or link,it will clear the menu active class,to fix this problem,we shoud made some change to function attr() on Lavary\Menu\Item and Lavary\Menu\Link

we should add one line of code in function attr()

public function attr()
   {
       $args = func_get_args();

      
       if (isset($args[0]) && is_array($args[0])) {
           if(isset($args[0]["class"]) && isset($this->attributes["class"])){                
                $args[0]["class"] = Builder::formatGroupClass($args[0],$this->attributes);
           }
              
           $this->attributes = array_merge($this->attributes, $args[0]);
           

           return $this;
       } elseif (isset($args[0]) && isset($args[1])) {
           $this->attributes[$args[0]] = $args[1];

           return $this;
       } elseif (isset($args[0])) {
           return isset($this->attributes[$args[0]]) ? $this->attributes[$args[0]] : null;
       }
      
       
       return $this->attributes;
   }

like abouve I have added the code

if(isset($args[0]["class"]) && isset($this->attributes["class"])){                
                $args[0]["class"] = Builder::formatGroupClass($args[0],$this->attributes);
           }
@dustingraham
Copy link
Collaborator

I can see where you are going with it, I think it is a good idea. Someone could open a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants