Skip to content

Fix project attribute text/integer fields not saving on blur - #24813

Open
tiago-lima-4linux wants to merge 1 commit into
opf:devfrom
tiago-lima-4linux:fix/project-attribute-text-field-not-saving-on-blur
Open

Fix project attribute text/integer fields not saving on blur#24813
tiago-lima-4linux wants to merge 1 commit into
opf:devfrom
tiago-lima-4linux:fix/project-attribute-text-field-not-saving-on-blur

Conversation

@tiago-lima-4linux

Copy link
Copy Markdown

What's wrong

Project attributes (project-level custom fields) of format string or integer silently fail to save when editing them inline from the project overview page, unless the user happens to press Enter. Clicking away to edit another attribute, or tabbing out, discards the typed value with no error shown.

IntegerInputComponent inherits directly from TextInputComponent without overriding the relevant method, so it has the exact same gap.

Why

TextInputComponent#additional_arguments only wires:

action: "keydown.esc->inplace-edit#request"

DateInputComponent, right next to it, correctly wires:

action: "keydown.esc->inplace-edit#request " \
        "keydown.enter->inplace-edit#submitForm " \
        "change->inplace-edit#submitForm"

TextInputComponent is missing both the keydown.enter and, more importantly, the change binding. Pressing Enter appears to work today, but only by accident: the edit form contains a single visible text input, so the browser's native implicit-submission-on-Enter kicks in regardless of application JS. Any interaction other than Enter (blur, Tab, clicking another field) never sends a request at all.

Interestingly, text_input_component_spec.rb already had a test titled "does not add a submit-on-change Stimulus action whe show_action_buttons is false" (same title, same typo, as the equivalent test in date_input_component_spec.rb), but its assertion only checked for keydown.esc, never for change->inplace-edit#submitForm. Looks like the spec was copied over when this component was written, but the matching implementation and assertion were not.

What this changes

  • Adds the same keydown.enter->inplace-edit#submitForm and change->inplace-edit#submitForm bindings that DateInputComponent already has, to TextInputComponent#additional_arguments.
  • Updates text_input_component_spec.rb to actually assert the new bindings are present (and absent when show_action_buttons: false), matching date_input_component_spec.rb's coverage.

Testing

  • Reproduced the bug live against a running 17.7.0 instance: confirmed via network inspection that no request was sent on blur/tab, and confirmed via direct DB query that the value was never persisted.
  • Built and ran a local instance with this fix applied: confirmed the field now saves on blur (PATCH .../update fires, value persists after reload).
  • Verified the bug is still present on dev as of this writing (checked before opening this PR).
  • I did not have a full local test environment set up to run the RSpec suite before opening this PR, the spec change follows the exact structure and assertions of the passing date_input_component_spec.rb, and I'd appreciate a check from CI on that.

TextInputComponent only wired keydown.esc, so text and integer format
project attributes (IntegerInputComponent inherits from TextInputComponent)
never submitted unless the user happened to press Enter, which only worked
by accident via the browser's native single-input-form implicit submission,
not through application JS. Clicking away to edit another field, or
tabbing out, silently discarded the value with no error shown.

DateInputComponent already wires keydown.enter and change to
inplace-edit#submitForm. This applies the same bindings to
TextInputComponent so it behaves consistently.

The existing spec file's test titles already said "does not add a
submit-on-change Stimulus action", copied from date_input_component_spec.rb,
but the assertions were never updated to actually check for it, so the gap
went uncaught. Updated the assertions to match.
@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@tiago-lima-4linux

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant