Skip to content

Editable argument name #13014

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

Merged
merged 19 commits into from
May 14, 2025
Merged

Editable argument name #13014

merged 19 commits into from
May 14, 2025

Conversation

Frizi
Copy link
Contributor

@Frizi Frizi commented May 1, 2025

Implement editing grouped component argument names.
Fixes #12911

edit-arg-names.mp4
  • Improved styling for function signature editor, now editable areas are looking like ports.
  • Signature editor now changes to "selected component" visual style when any of the widgets inside are in focus.
  • Fixed keyboard focus handling for "remove" buttons between list elements. Focused icons are now clearly highlighted and can be keyboard activated using enter.
  • Added a way to perform input validation by wrapping widgets, used here to only allow identifiers for argument name inputs.
arg-name-validation-error.mp4

Important Notes

Fairly big code changes included:

  • Refactor of the widget update mechanism: onUpdate now returns an update result and can be async. That allows widgets to properly handle error states caused by their attempted updates. Injecting an update processor in the middle of the chain also allows for inesrting additional input validation by intermediate widgets (used by argument name editor to only accept Ast.Expr patterns).
  • Deduplicate fairly complicated setup code from widgets that used codemirror. Now there is a common CodeMirrorWidgetBase component that abstracts away most of the complexities of dealing with the editor, while allowing it to still be configurable (e.g. adding extra extensions). Only the final conversion of widget input data into text and emitting the final edit remains a responsibility of individual widgets. This common layer is now used by WidgetText, WidgetFunctionName and WidgetEnsoExpression, but more widgets with any form of text input can be later ported as needed.
  • Slightly cleaned up duplicated styling for common widget UI patterns, introduced widgetPill shared class.

Comment on lines +55 to +66
const allWidgetsComputed = [
mkWidget(() => definition.open),
mkWidget(() => definition.open2),
mkWidget(() => definition.suspension),
mkWidget(() => definition.pattern, patternWidget),
mkWidget(() => definition.type?.operator),
mkWidget(() => definition.type?.type),
mkWidget(() => definition.close2),
mkWidget(() => definition.defaultValue?.equals),
mkWidget(() => definition.defaultValue?.expression),
mkWidget(() => definition.close),
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use argumentDefinitionToConcrete

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a special case in the middle, pattern has a different widget kind and soon other parts (type, default value expression) will have different ones as well.

Copy link

github-actions bot commented May 2, 2025

🧪 Storybook is successfully deployed!

📊 Dashboard:

@Frizi Frizi added the CI: No changelog needed Do not require a changelog entry for this PR. label May 3, 2025
@Frizi
Copy link
Contributor Author

Frizi commented May 3, 2025

Added "no changelog needed" as a workaround for broken CI changelog check. The changelog entry is present in the PR.

@Frizi Frizi force-pushed the wip/frizi/editable-argument-name-type branch from 5902ea5 to e17b8b5 Compare May 13, 2025 13:04
@Frizi Frizi added the CI: Ready to merge This PR is eligible for automatic merge label May 13, 2025
@mergify mergify bot merged commit c0e9d09 into develop May 14, 2025
62 of 64 checks passed
@mergify mergify bot deleted the wip/frizi/editable-argument-name-type branch May 14, 2025 18:12
@Frizi Frizi restored the wip/frizi/editable-argument-name-type branch May 14, 2025 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Grouped Components - Editing argument names
3 participants