Skip to content

Commit

Permalink
fix(context-pad): add title to remove button
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklas Kiefer committed Nov 2, 2023
1 parent 3be4ad3 commit acb01b3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/form-js-editor/src/render/components/FormEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ function Element(props) {
const eventBus = useService('eventBus'),
formEditor = useService('formEditor'),
formFieldRegistry = useService('formFieldRegistry'),
formFields = useService('formFields'),
modeling = useService('modeling'),
selection = useService('selection');

Expand Down Expand Up @@ -187,7 +188,7 @@ function Element(props) {
<ContextPad>
{
selection.isSelected(field) && field.type !== 'default'
? <button class="fjs-context-pad-item" onClick={ onRemove }><DeleteIcon /></button>
? <button title={ getRemoveButtonTitle(field, formFields) } class="fjs-context-pad-item" onClick={ onRemove }><DeleteIcon /></button>
: null
}
</ContextPad>
Expand Down Expand Up @@ -579,4 +580,14 @@ function findPaletteEntry(type, formFields) {

function defaultPropertiesPanel(propertiesPanelConfig) {
return !(propertiesPanelConfig && propertiesPanelConfig.parent);
}

function getRemoveButtonTitle(formField, formFields) {
const entry = findPaletteEntry(formField.type, formFields);

if (!entry) {
return 'Remove form field';
}

return `Remove ${entry.label}`;
}

0 comments on commit acb01b3

Please sign in to comment.