There is 1 comment.
 
 
XWiki Platform / cid:jira-generated-image-avatar-e2dffd5b-21b1-4d68-8f30-88084259623e XWIKI-23503 Open

'Submit' button is active although no document is uploaded in the Office Document Viewer Macro

 
View issue   ·   Add comment
 

1 comment

 
cid:jira-generated-image-avatar-6b7e73b6-3539-4e1b-a6a2-7a03370345b8 Charpentier Lucas on 02/Sep/26 14:22
 
  • The macro insertion dialog does not disable Submit on purpose: `macroEditor.js` validates
      on submit, aborting the insertion and flagging the first empty mandatory parameter.
  • `OfficeMacroParameters` declares no mandatory parameter: neither `setReference` nor the
      deprecated `setAttachment` carries `@PropertyMandatory` / `@PropertyFeature(mandatory = true)`.
  • So the parameter is not flagged as mandatory in the descriptor, validation passes, the macro is
      inserted without a `reference`, and the failure only shows at render time as the error in
      `OfficeMacro.getResourceReference` (the stack trace in the second comment).

The bug is the missing mandatory declaration, not the enabled Submit button.
___

`reference` and the deprecated `attachment` are two ways to give the same information, so a plain
`@PropertyMandatory` would break existing `office attachment="f.doc"/` content. The "exactly
one of these" mechanism already exists – the Include macro uses it for `reference` / `page`.

Proposal: put `@PropertyFeature(value = "reference", mandatory = true)` on *both* office setters.

  • UI: one feature group; `attachment` is deprecated and unset, so it is hidden and no radio buttons
      appear – just the reference field labelled "(required)", blocking an empty submit.
  • Server side: `DefaultBeanManager.checkFeatureMandatory` throws when neither parameter is set, so
      wiki syntax and quick actions get a proper parameter error too; existing content still validates.

Details: `checkFeatureMandatory` only checks presence, so `attachment=""` still passes and the
runtime check in `OfficeMacro` must stay; the feature name needs a translation.

Out of scope: greying out Submit until required fields are filled is a generic `macroEditor.js`
change affecting every macro, i.e. the design page linked above.

Tests: `xwiki-platform-office-macro` has no `src/test` yet, so either a new unit test on the macro
descriptor there or an assertion in the WYSIWYG macro-editor Docker IT.