mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
Fix: Escape button not being handled on settings pages (#1210)
* fix: escape button handler * feat: location logic for settings page * fix: linting errors * fix: linting error * refactor: settings test
This commit is contained in:
parent
edbf4eb3d6
commit
23786b444a
5 changed files with 37 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
include AutoSync, Authentication, Invitable, SelfHostable
|
||||
include AutoSync, Authentication, Invitable, SelfHostable, StoreLocation
|
||||
include Pagy::Backend
|
||||
|
||||
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
|
||||
|
|
31
app/controllers/concerns/store_location.rb
Normal file
31
app/controllers/concerns/store_location.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module StoreLocation
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
helper_method :previous_path
|
||||
before_action :store_return_to
|
||||
after_action :clear_previous_path
|
||||
end
|
||||
|
||||
def previous_path
|
||||
session[:return_to] || fallback_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def store_return_to
|
||||
if params[:return_to].present?
|
||||
session[:return_to] = params[:return_to]
|
||||
end
|
||||
end
|
||||
|
||||
def clear_previous_path
|
||||
if request.fullpath == session[:return_to]
|
||||
session.delete(:return_to)
|
||||
end
|
||||
end
|
||||
|
||||
def fallback_path
|
||||
root_path
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue