techiferous / tabulous

Easy tabbed navigation for Rails
Other
322 stars 35 forks source link

Feature: Display tabs even if no active tab is present #7

Closed eploko closed 12 years ago

eploko commented 12 years ago

The previous behavior was not to render the tabs at all if there was no tab defined for the current controller-action pair. I've stumbled on this in my current project where the tabs don't cover all of the possible controllers. Some of the controllers are reached from a drop-down in the navigation bar and there are no tabs for them. This led to the fact that as soon as the user clicked on a link in the drop-down and happened to be on a page for a controller not covered by the tabs, all of the navigation for the rest of the site (effectively rendered as tabs) was gone. Oops.

I've added an option to the Options class to augment the rendering behavior (render_tabs_if_no_tab_found) and changed the Tabulous class to treat it well.

By default, when an action renders and no tab is defined for that action, the tabs are simply not rendered. If you turn this on, the tabs are still rendered, though no tab will be active.

techiferous commented 12 years ago

Andrey, thank you so much for taking the time to improve tabulous.

I took your idea and made it into an even bolder change. Instead of having two different configuration settings:

config.raise_error_if_no_tab_found
config.render_tabs_if_no_tab_found

I replaced it with just one setting: config.when_action_has_no_tab. The values can be :raise_error, :render, or :do_not_render.

I updated the gem and released it as version 1.1.0.