vinistock / sail

Sail is a lightweight Rails engine that brings an admin panel for managing configuration settings on a live Rails app
Other
507 stars 32 forks source link

Disable buttons unless form is dirty #349

Closed vinistock closed 3 years ago

vinistock commented 3 years ago

Partial implementation of #340.

Make submit buttons disabled and grayed out by default. When a value is changed in an input, the corresponding button becomes enabled and orange as was the previous style.

Saving a new value for a setting will also cause the button to become disabled and only a second change will then enable it again.

@denny let me know what you think.

codecov[bot] commented 3 years ago

Codecov Report

Merging #349 (37ba123) into master (5cdd160) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #349   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           62        62           
  Lines         1644      1646    +2     
=========================================
+ Hits          1644      1646    +2     
Impacted Files Coverage Δ
spec/features/editing_settings_feature_spec.rb 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5cdd160...37ba123. Read the comment docs.

denny commented 3 years ago

Ooh, nice :smile: Thanks!

I think you need to key into a different JavaScript event for the text inputs - they're not updating the button status until I leave the input, which means I can't click the submit button straight after typing a new value in. I think there's an 'input' event for text and textarea that triggers as soon as you type the first new character?

vinistock commented 3 years ago

Oh, nice! I didn't know about the input event before. It will now enable the button as soon as typing happens.