You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to be able to show the save bar when a user tries to save an invalid value. Currently if the user submits an invalid combination, the form will show errors, but the bar will disappear and the user can leave the page. In this case, the data was never persisted, so its not possible for them to know it has issues.
Also in other situations, its sometimes easier to manage the state of a form not in the DOM, especially in the case of arrays.
Manually supplying if a form is dirty would be a massive upgrade.
Alternative tried
For arrays, I've got this dumb helper:
exportfunctionHiddenArrayInput<T>({
original,
current,}: {original: T[];current: T[];}){
const id=useId();constref=useRef<HTMLInputElement>(null);useEffect(()=>{// compare it to the default valueconstoriginalValue=original.map((item)=>{returnJSON.stringify(item);}).join(",");constcurrentValue=current?.map((item)=>{returnJSON.stringify(item);}).join(",");if(originalValue===currentValue){return;}// any time the value changes, fire aaaan eventconstevent=newEvent("input",{bubbles: true,});ref.current?.dispatchEvent(event);},[id,current,original]);return(<inputhiddenref={ref}id={id}readOnly={true}value={current?.map((item)=>{returnJSON.stringify(item);}).join(",")}/>);}
The text was updated successfully, but these errors were encountered:
nick-potts
changed the title
Ability to mark form as dirty after submit and show a save-bar.
Ability to supply a data-save-bar's dirty status
Oct 4, 2024
I'd like to be able to show the save bar when a user tries to save an invalid value. Currently if the user submits an invalid combination, the form will show errors, but the bar will disappear and the user can leave the page. In this case, the data was never persisted, so its not possible for them to know it has issues.
Also in other situations, its sometimes easier to manage the state of a form not in the DOM, especially in the case of arrays.
Manually supplying if a form is dirty would be a massive upgrade.
Alternative tried
For arrays, I've got this dumb helper:
for errors, I've got this helper:
The text was updated successfully, but these errors were encountered: