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

Right-to-Left support for form elements (text field, text area, select, etc.) #4306

Open
okaeiz opened this issue May 23, 2024 · 23 comments
Open
Assignees
Labels
backlog Queued in backlog enhancement New feature or request Forms

Comments

@okaeiz
Copy link

okaeiz commented May 23, 2024

Problem you would like to solve

I have just updated the Modeler to v5.23.0 and I can see a HTML View component is added and it is great for customization and font changes, especially for RTL languages like Persian and Arabic. But as declared in the official docs, the section on security and sanitation strategy, it's for information presentation purposes only. Therefore, it cannot be used for input fields.

On the other hand, the input fields (such as text fields or date-time) do not support right-to-left languages. It can be frustrating when creating forms in those languages.

Proposed solution

Alternatives considered

First, I thought I could achieve this by creating input fields in HTML View element but since it is disabled due to XSS and clickjacking attacks, it doesn't seem like a good idea. Moreover, the passing of values in the workflow may be tricky in this way.

Additional context

No response


Depends on bpmn-io/form-js#1185

@okaeiz okaeiz added the enhancement New feature or request label May 23, 2024
@nikku
Copy link
Member

nikku commented May 23, 2024

As I understand your feature request is support for RTL languages, right? How would you envision such support? I'd assume it would be globally applied (per form)?

@nikku nikku added the Forms label May 23, 2024
@okaeiz
Copy link
Author

okaeiz commented May 23, 2024

Yes. In forms, it'd be awesome if we could choose the direction for each element (maybe via the properties panel). Then the element positioning may be done using the resize option. However, I also noticed this unusual behavior for resizing elements which is discussed here as well.

@nikku
Copy link
Member

nikku commented May 23, 2024

What is the use case for maintaining RTL for each element? Do you envision forms to mix RTL and LTR language inputs?

@volodymyr-melnykc
Copy link

Related issue: bpmn-io/form-js#1185

@okaeiz
Copy link
Author

okaeiz commented May 23, 2024

No. It is not necessary for the form to include input values in both English and non-English languages.

Maybe it's just better to be a preference setting for the whole form. It can be added to the form properties where we can set its unique ID.

@nikku
Copy link
Member

nikku commented May 24, 2024

It is not necessary for the form to include input values in both English and non-English languages.

This is what I thought, too. Thanks for confirming.


Could you create another FR for this issue:

* Also, the Jalali calendar support for date-time element is also requested.

@okaeiz
Copy link
Author

okaeiz commented May 29, 2024

I'd be grateful if you guys keep me informed of this issue. It's of high importance for my organization.

@nikku
Copy link
Member

nikku commented May 29, 2024

@okaeiz Consider to contribute if this is important to your organization.

@nikku nikku added the backlog Queued in backlog label Jun 3, 2024 — with bpmn-io-tasks
@okaeiz
Copy link
Author

okaeiz commented Jun 9, 2024

I have played around with adding custom components to form-js and I managed to create an RTL text input field which has RTL labels and values. But I think the form-js repository seems forgotten and nothing is happening there exactly. Should I consider contributing to Modeler?

Capture

As you can see, I have created a Text Input RTL form component. I'm looking for a proper icon for it.

@nikku
Copy link
Member

nikku commented Jun 10, 2024

@okaeiz As we discussed:

Let's not require users to configure it locally, but rather inherit the value from the global form configuration, if provided. Or did you change your mind and think that this provides value to configure it for each element indivudually?

I'm not sure why you'd want a separate Text Input RTL when you could configure the text direction (LTR or RTL) for these components.

@volodymyr-melnykc
Copy link

@okaeiz Thanks a lot for working on it! The form-js repository is active, and you can contribute to it. I agree with @nikku's comments. Rather than having separate RTL components, we can extend existing ones (text field, text area, select etc.) with the direction (left or right).

@Skaiir
Copy link
Contributor

Skaiir commented Jun 10, 2024

@okaeiz We're currently in a large refactor on form-js which is why a lot of the other topics have taken a backseat, but it is definitely where such a feature should be contributed. I can offer some guidance on the issue you raised there as well, but generally I agree where this discussion is going.

I'll get into more detail on the form-js issue, but one single boolean config should drive this feature. No custom components needed.

@okaeiz
Copy link
Author

okaeiz commented Jun 10, 2024

@nikku @volodymyr-melnykc @Skaiir I appreciate your guidance.

Let's not require users to configure it locally, but rather inherit the value from the global form configuration, if provided. Or did you change your mind and think that this provides value to configure it for each element individually?

Absolutely not. I adhere to what we've discussed before. I was just following the official Camunda docs, the section on Custom components and its examples because I didn't fully comprehend what exact part of the form-js codebase I should head to in order to define a global RTL option for the form.

The form-js repository is active, and you can contribute to it.

Is it the form-js-editor package that I need to play around with? I am definitely ready to contribute and will be grateful if you help me find the proper spot of the codebase. Here's what I think I should do:

Capture

I need to add another section to the panel (maybe?) in addition to General and create a toggle switch which is The form is right-to-left. And then, I need to follow the instructions about the base fields' conditions that are given in this form-js issue. Do you confirm?

@volodymyr-melnykc
Copy link

volodymyr-melnykc commented Jun 11, 2024

@okaeiz I suggest adding the direction property for individual components rather than a form.
Each component has a Layout section. The Direction property can be placed there, with the Left option as a default one and the Right as an alternative.
For example, here's how it can look:

Form component direction

@Skaiir
Copy link
Contributor

Skaiir commented Jun 11, 2024

@volodymyr-melnykc Does this really make sense? I'm not sure there's a use case to have two different text directions within the same form.

@okaeiz To answer your initial question, the form-js-editor package will contain where you need to add the properties panel entry, there's tons of files ending with Entry that will show you how it works. The form-js-viewer package is where you have to add the implementation to individual components, just search component names and you'll find those.

Also, regarding what I mentioned in the other issue, forget about it, it's for external configuration only, we can handle this later ourselves when we'll need it ;)

@okaeiz
Copy link
Author

okaeiz commented Jun 11, 2024

@Skaiir @volodymyr-melnykc Thank you; I'll look into it. I think these solutions are both useful in specific cases.
Global solution is simpler and reduces the risk of errors and inconsistencies since there's only one place to manage RTL settings. Individual solution is useful in case of bilingual forms and where different types of data is asked from the user.

For instance, we may ask Persian users to enter their full name and profession - which is RTL - and their company website URL - which is LTR - and it may require separate options for each form component.

Personally I prefer the global solution but it's actually up to you to decide.

@volodymyr-melnykc
Copy link

@okaeiz After having an internal discussion about it, the direction can be defined on a form level, so you can disregard my previous comment.
As you proposed, you can add a new section to the form's panel (can be called 'Appearance') under the General section.

@okaeiz
Copy link
Author

okaeiz commented Jun 11, 2024

@volodymyr-melnykc @Skaiir
Alright. I will be working on it soon. I'm still doubtful about the email, URLs and numbers (numbers are always written LTR).
Now what do you think about this idea?
I create the global direction option for the form; but still implement a direction option for Text Field (and only Text Field because that's where all the doubt is caused) in case people intend to enter number values, emails and URLs.

@okaeiz
Copy link
Author

okaeiz commented Jun 15, 2024

RTL-Demo.mp4

@volodymyr-melnykc @Skaiir I added the global entry for the form and I'm starting to make it affect all the components. I have also added a preferred font to Persian strings. Is it okay?

@volodymyr-melnykc
Copy link

@okaeiz It looks good!
How did you define a preferred font?

@okaeiz
Copy link
Author

okaeiz commented Jun 17, 2024

I used a Google valid font in the style attribute. I plan to apply it only when the direction is RTL. However, It looks decent on the non-Persian strings too.

@okaeiz
Copy link
Author

okaeiz commented Jul 13, 2024

Hey there! @volodymyr-melnykc
It's been two weeks that I have made a pull request in form-js repo but I haven't received any responses yet. Did I do something wrong?
This RTL issue is of high importance for us. Now that we have started working on it, we'd appreciate your help.

@okaeiz
Copy link
Author

okaeiz commented Oct 31, 2024

Hey there! I just got 5.29.0-dev and I noticed it has a file picker component and it's great. I think if you take a look at my PR and review the options on right to left support and Jalali datepicker, it would attract a massive amount of people to the software.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Queued in backlog enhancement New feature or request Forms
Projects
None yet
Development

No branches or pull requests

4 participants