Controlled Props
The v3ControlledRestore future flag keeps props that hold state the user edits at the value the app renders, as React DOM does for a controlled input. It becomes the default in the next major version.
Restoring the rendered value
When the user, or GTK itself, changes the value of a covered prop, GTKX restores the rendered value before the next frame, unless a handler renders the new value or another one, such as uppercased text. Rendering the element again also resets a widget that holds another value. Leaving the prop out, or passing undefined, leaves the value to the widget; removing the prop keeps the value the widget holds.
Covered props
The flag covers text on editable widgets such as GtkEntry and AdwEntryRow and on text buffers such as GtkTextBuffer and GtkSourceBuffer, active on GtkCheckButton, GtkToggleButton, GtkSwitch and AdwSwitchRow, value on GtkSpinButton, GtkAdjustment and AdwSpinRow, selected on GtkDropDown, AdwComboRow and AdwSidebar, expanded on GtkExpander and AdwExpanderRow, enableExpansion on AdwExpanderRow, page on GtkNotebook, visiblePageName on AdwPreferencesDialog and AdwPreferencesWindow, and position on GtkPaned. A value on the adjustment of a scrolled window therefore fixes its scroll position. A pane's position stays within the range its size allows: a position out of reach settles on the nearest one the pane accepts, and the pane returns to the rendered position once it has room. Without the flag, these props are written only when their rendered value changes, so a change the handler ignores stays, and leaving a prop out resets some of them to their default.
Updating from a handler
Render the new value while the handler runs. An update made later, after an await, inside startTransition, or from a signal GTK delays, comes after the restore, so the widget shows the old value until it commits. On a GtkSearchEntry, update text from onChanged: onSearchChanged runs after GTK's search delay, so every keystroke is restored before it arrives.
Text buffers and undo
A text buffer keeps its undo history: the text GTKX writes back after an edit, whether it restores the old text or shows text the handler transformed, is recorded as an edit instead of clearing the history. Text the app renders on its own, such as a newly opened file, still replaces the history. A handler that rewrites or rejects text blocks Undo at that edit, as a controlled input that rewrites its value does in a browser.
Windows, popovers and menus
The flag also covers visible on windows and popovers and active on GtkMenuButton. GTKX refuses every close request of a window given visible, including one from close(), once onCloseRequest has run, so the window stays open until the app renders visible={false}. That hides it without destroying it: it stays one of the application's windows and keeps the app running, and visible={true} shows it again. A handler that returns true still keeps the window as it is. GTKX refuses after GTK's default handler, so a handler connected to run after it, as useSignal does with isAfter: true, never sees the close; handle it in onCloseRequest or a handler connected without isAfter. With hideOnClose, GTK hides the window before GTKX can refuse the close, and GTKX shows it again unless the app renders visible={false}. Removing the prop leaves the window, popover or menu as it is.
A window that passes visible without setting it to false from onCloseRequest can no longer be closed by the user. Closing lists the handler that answers each close.