Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(context-pad): add title to remove button #877

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
const eventBus = useService('eventBus'),
formEditor = useService('formEditor'),
formFieldRegistry = useService('formFieldRegistry'),
formFields = useService('formFields'),
modeling = useService('modeling'),
selection = useService('selection');

Expand Down Expand Up @@ -114,7 +115,7 @@
eventBus.on('selection.changed', scrollIntoView);

return () => eventBus.off('selection.changed', scrollIntoView);
}, [ id ]);

Check warning on line 118 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04, 20)

React Hook useEffect has missing dependencies: 'eventBus' and 'scrollIntoView'. Either include them or remove the dependency array

Check warning on line 118 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (macos-latest, 20)

React Hook useEffect has missing dependencies: 'eventBus' and 'scrollIntoView'. Either include them or remove the dependency array

Check warning on line 118 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04, 20)

React Hook useEffect has missing dependencies: 'eventBus' and 'scrollIntoView'. Either include them or remove the dependency array

Check warning on line 118 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (macos-latest, 20)

React Hook useEffect has missing dependencies: 'eventBus' and 'scrollIntoView'. Either include them or remove the dependency array

Check warning on line 118 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20)

React Hook useEffect has missing dependencies: 'eventBus' and 'scrollIntoView'. Either include them or remove the dependency array

Check warning on line 118 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20)

React Hook useEffect has missing dependencies: 'eventBus' and 'scrollIntoView'. Either include them or remove the dependency array

useLayoutEffect(() => {
if (selection.isSelected(field)) {
Expand Down Expand Up @@ -187,7 +188,7 @@
<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 @@ -326,7 +327,7 @@
return () => {
eventBus.off('selection.changed', handleSelectionChanged);
};
}, [ schema, selection ]);

Check warning on line 330 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04, 20)

React Hook useEffect has a missing dependency: 'eventBus'. Either include it or remove the dependency array

Check warning on line 330 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (macos-latest, 20)

React Hook useEffect has a missing dependency: 'eventBus'. Either include it or remove the dependency array

Check warning on line 330 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04, 20)

React Hook useEffect has a missing dependency: 'eventBus'. Either include it or remove the dependency array

Check warning on line 330 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (macos-latest, 20)

React Hook useEffect has a missing dependency: 'eventBus'. Either include it or remove the dependency array

Check warning on line 330 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20)

React Hook useEffect has a missing dependency: 'eventBus'. Either include it or remove the dependency array

Check warning on line 330 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20)

React Hook useEffect has a missing dependency: 'eventBus'. Either include it or remove the dependency array

const [ drake, setDrake ] = useState(null);

Expand Down Expand Up @@ -404,7 +405,7 @@

// keep deprecated event to ensure backward compatibility
eventBus.fire('formEditor.rendered');
}, []);

Check warning on line 408 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04, 20)

React Hook useEffect has a missing dependency: 'eventBus'. Either include it or remove the dependency array

Check warning on line 408 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (macos-latest, 20)

React Hook useEffect has a missing dependency: 'eventBus'. Either include it or remove the dependency array

Check warning on line 408 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04, 20)

React Hook useEffect has a missing dependency: 'eventBus'. Either include it or remove the dependency array

Check warning on line 408 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (macos-latest, 20)

React Hook useEffect has a missing dependency: 'eventBus'. Either include it or remove the dependency array

Check warning on line 408 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20)

React Hook useEffect has a missing dependency: 'eventBus'. Either include it or remove the dependency array

Check warning on line 408 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20)

React Hook useEffect has a missing dependency: 'eventBus'. Either include it or remove the dependency array

const [ hoveredId, setHoveredId ] = useState(null);

Expand Down Expand Up @@ -565,7 +566,7 @@
drake.on('cloned', handleCloned);

return () => drake.off('cloned', handleCloned);
}, [ drake ]);

Check warning on line 569 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04, 20)

React Hook useEffect has a missing dependency: 'handleCloned'. Either include it or remove the dependency array

Check warning on line 569 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (macos-latest, 20)

React Hook useEffect has a missing dependency: 'handleCloned'. Either include it or remove the dependency array

Check warning on line 569 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04, 20)

React Hook useEffect has a missing dependency: 'handleCloned'. Either include it or remove the dependency array

Check warning on line 569 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (macos-latest, 20)

React Hook useEffect has a missing dependency: 'handleCloned'. Either include it or remove the dependency array

Check warning on line 569 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20)

React Hook useEffect has a missing dependency: 'handleCloned'. Either include it or remove the dependency array

Check warning on line 569 in packages/form-js-editor/src/render/components/FormEditor.js

View workflow job for this annotation

GitHub Actions / Build (windows-latest, 20)

React Hook useEffect has a missing dependency: 'handleCloned'. Either include it or remove the dependency array

return null;
}
Expand All @@ -579,4 +580,14 @@

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}`;
}
Loading