Commit a1f4569d authored by charlie ablett's avatar charlie ablett

Merge branch 'ps-fix-new-dropdown-with-no-items' into 'master'

Fix new dropdown showing on mobile with no items

See merge request gitlab-org/gitlab!64268
parents ed26027d fec8a11d
......@@ -22,7 +22,7 @@ module Nav
new_view_model = new_dropdown_view_model(project: project, group: group)
if new_view_model
if new_view_model && new_view_model.fetch(:menu_sections)&.any?
builder.add_view(NEW_VIEW, new_view_model)
end
......
......@@ -539,10 +539,18 @@ RSpec.describe Nav::TopNavHelper do
end
context 'with new' do
let(:with_new_view_model) { { id: 'test-new-view-model' } }
let(:with_new_view_model) { { menu_sections: [{ id: 'test-new-view-model' }] } }
it 'has new subview' do
expect(subject[:views][:new]).to eq({ id: 'test-new-view-model' })
expect(subject[:views][:new]).to eq(with_new_view_model)
end
end
context 'with new and no menu_sections' do
let(:with_new_view_model) { { menu_sections: [] } }
it 'has new subview' do
expect(subject[:views][:new]).to be_nil
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment