writer-framework icon indicating copy to clipboard operation
writer-framework copied to clipboard

custom component name should be constrained explicitely

Open ZBMO opened this issue 1 year ago • 3 comments

Custom component names defined by the dev in custom_components/index.ts must contain the full original name of the component lower-case.

For example, A customized the Metric component called "customMetric", compiles but can't be dragged into the ComponentRenderer, whereas "custommetric" and "nonsensemetric" work fine. AFAIK the constraints for naming are not in the docs. video of the behavior from the invalid name is below

https://github.com/user-attachments/assets/4d9c69e6-5511-47be-90aa-d1f79447292e

ZBMO avatar Aug 15 '24 02:08 ZBMO

I was able to reproduce this bug.

FabienArcellier avatar Aug 15 '24 05:08 FabienArcellier

The problem comes from the DataTransfer protocol. Doing setData set the value in lowercase.

image

image

We need to know the component type for drag n drop. We cannot fully use the protocol because getData can only be used during drop, not on over. More about the limitation : https://stackoverflow.com/questions/28487352/dragndrop-datatransfer-getdata-empty

Solution proposal

  • transform dynamically the id from custom_components/index into lowercase
  • raise error if id in custom_components/index use other character than [a-z]

FabienArcellier avatar Aug 15 '24 06:08 FabienArcellier

We decide to go on raising error if id in custom_components/index use other character than [a-z]

FabienArcellier avatar Aug 15 '24 11:08 FabienArcellier

it's available in release 0.8.1

FabienArcellier avatar Nov 30 '24 11:11 FabienArcellier