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

[FR]: 期望Form表单保留required 的label占位或者说如果是左布局的时候应保留 #1405

Closed
codedart2018 opened this issue Sep 7, 2023 · 1 comment · Fixed by #1412

Comments

@codedart2018
Copy link

codedart2018 commented Sep 7, 2023

这个功能解决了什么问题?

当布局为 labelPosition='left'的时候,不是所有字段都是必填的。本身在移动端空间有限,大多时候大家都是左布局。现在的节点就面临这个情况如果不required 那么将导致布局难看,如下图所示。
image
虽然我可以自己处理。但还是希望能更改下展示方式。

import * as React from 'react';
import { Text } from '@tarojs/components';
import { Form, Input } from '@nutui/nutui-react-taro';
import { InputFormItemProps } from './types';

const InputFormItem: React.FC<InputFormItemProps> = (props) => {
  const { required, label, name, placeholder } = props;

  return (
    <Form.Item
      required={required}
      name={name}
      label={required ? label : <><Text style={{ display: 'inline-block', width: 11 }} />{label}</>}
    >
      <Input placeholder={placeholder ? placeholder : `请选择${label}`} type='text' />
    </Form.Item>
  );
};

export default InputFormItem;

你期望的组件设计是怎样的?

期望把组件的 * 号label改成 position: absolute; label 本体用padding把文字顶走留出*的占位。这样无论我表单是不是强制的都没关系,它这样不会影响我们页面布局和美观。期望能修改实现。

@ivan-My
Copy link
Contributor

ivan-My commented Sep 7, 2023

还没碰到过右布局,感觉starPosition多余

@oasis-cloud oasis-cloud linked a pull request Sep 8, 2023 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants