components icon indicating copy to clipboard operation
components copied to clipboard

mat-input DOM order of label and input

Open bsteffl opened this issue 9 years ago • 7 comments

Bug, feature request, or proposal:

Proposal

What is the expected behavior?

It would be ideal if the label came before the input in the DOM order for the mat-input. Useful for adding your own custom styles if you want the functionality default look of inputs. This would also be useful if CSS were disabled.

What is the current behavior?

Label comes after input, however it has the appropriate aria labels and markup to associate the label with the input.

What are the steps to reproduce?

Providing a StackBlitz/Plunker (or similar) is the best way to get the team to see your issue.
Plunker starter (using on @master): https://goo.gl/DlHd6U
StackBlitz starter (using latest npm release): https://goo.gl/wwnhMV

DOM order
image

CSS disabled
image

What is the use-case or motivation for changing an existing behavior?

For applying custom styling to make form fields look like traditional inputs can cause complications when DOM order is flipped. Also useful if CSS was disabled.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Material 2.0.0-beta.11

bsteffl avatar Sep 29 '17 00:09 bsteffl

For reference, the reason for this DOM order is to allow us to use the autofill selectors to float the label when the input has been pre-filled by the browser.

crisbeto avatar Oct 04 '17 05:10 crisbeto

@crisbeto I haven't looked at the details of the styling for floating the label, but I'm guessing it's not something resolved by flexbox and order?

bsteffl avatar Oct 12 '17 22:10 bsteffl

It's not. If you look at this, the selector depends on the input coming before the label in the DOM order.

crisbeto avatar Oct 13 '17 06:10 crisbeto

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

angular-robot[bot] avatar Feb 01 '22 18:02 angular-robot[bot]

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

angular-robot[bot] avatar Feb 21 '22 15:02 angular-robot[bot]

We're in the process of cleaning up our issue backlog. I'm closing this issue, because there hasn't been any activity in a long time and the current DOM structure is intentional.

crisbeto avatar Jun 28 '22 12:06 crisbeto

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.