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

[FluentFileInput] adds a "disabled" property to the FluentFileInput component #1404

Conversation

NickHirras
Copy link
Contributor

@NickHirras NickHirras commented Jan 29, 2024

Pull Request

📖 Description

I'm using the FluentFileInput component in a project. I have a requirement to disable the file upload field under certain conditions.

All HTML input components, including the native input type=file, support a disabled attribute.

This pull request adds a disabled property to the FluentFileInput component. When this attribute is set, a CSS class is applied to the container making it appear more translucent / lighter, as well as disabling cursor events on the component, and setting the embedded input type=file component to be disabled.

This PR also includes updated unit tests to cover the new property.

This PR also updates the demo project to add an example of this component in the disabled state.

image

🎫 Issues

👩‍💻 Reviewer Notes

I considered trying to add all the other missing standard input component attributes, but I wasn't comfortable with that level of change. And it's outside the scope of what I need at the moment. It may be more appropriate to extend input component instead of base component and inherit those additional attributes.

📑 Test Plan

✅ Checklist

General

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Component-specific

  • I have added a new component
  • I have added Unit Tests for my new compontent
  • I have modified an existing component
  • I have validate Unit Tests for an existing component

⏭ Next Steps

@NickHirras
Copy link
Contributor Author

@microsoft-github-policy-service agree

@NickHirras NickHirras marked this pull request as ready for review January 29, 2024 21:54
Copy link
Collaborator

@vnbaaij vnbaaij left a comment

Choose a reason for hiding this comment

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

Looks good (apart from the 2 remarks I made). Thanks for your contribution. Once requested changes are made, we can merge this in soon.

@vnbaaij vnbaaij added this to the V4.3.2 milestone Jan 29, 2024
@NickHirras
Copy link
Contributor Author

@vnbaaij requested changes have been pushed.

@vnbaaij vnbaaij merged commit b59ffe4 into microsoft:dev Jan 29, 2024
2 checks passed
@NickHirras NickHirras deleted the nickhirras/adds-disable-prop-to-fluentfileinput branch January 29, 2024 22:22
}

.fluent-inputfile-container.disabled {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's NOT a good idea to add a disabled class with a common name like that.
If a developer uses another library or style like this, it will have an impact on this component.

.disabled {
    color: red;
}

It would be better to add a disabled attribute to the <div class="fluent-inputfile-container"> tag and add a style such as the following:

.fluent-inputfile-container[disabled], .fluent-inputfile-container[disabled="true"] {
  ...
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fixing it in separate commit (also for v3)

vnbaaij pushed a commit that referenced this pull request Jan 30, 2024
…omponent (#1404)

* adds disabled property and supporting css class

* adds disabled fluent file input to demo app

* adds unit test for disabled component state

* adds disabled state component to demo

* removes unnecessary reference in tests project

* example has been simplified
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 this pull request may close these issues.

None yet

3 participants