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

bug in dropdown() #67

Open
douglassdavis opened this issue Aug 15, 2023 · 0 comments · May be fixed by #68 or #69
Open

bug in dropdown() #67

douglassdavis opened this issue Aug 15, 2023 · 0 comments · May be fixed by #68 or #69

Comments

@douglassdavis
Copy link

There appears to be a bug in dropdown(). If only $order, but not $attributes is passed in, the index 2 is incorrect for attributes and $attributes will end up having the integer value for $order. Perhaps check $order to make sure it's an array if people leave $order out of the arguments? Will fix and create pull request as soon as I can figure out how to set up my SSH keys. Let me know if I am incorrect.

   public function dropdown($title, \Closure $callback, $order = null, array $attributes = array())
    {
        $properties = compact('title', 'order', 'attributes');

        if (func_num_args() == 3) {
            $arguments = func_get_args();

            $title = Arr::get($arguments, 0);

            // If only $order is passed in without attributes, 2 is the wrong index
            $attributes = Arr::get($arguments, 2);

            $properties = compact('title', 'attributes');
        }

        $item = MenuItem::make($properties);

        call_user_func($callback, $item);

        $this->items[] = $item;

        return $item;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant