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

Additional props for keyboard helpers (input components with "hidden accessible" elements) #1852

Closed
Xerphis opened this issue Mar 6, 2021 · 0 comments · Fixed by #3186 or #3323
Closed
Assignees
Labels
Component: Accessibility Issue or pull request is related to WCAG or ARIA Type: New Feature Issue contains a new feature or new component request
Milestone

Comments

@Xerphis
Copy link

Xerphis commented Mar 6, 2021

I'm submitting a ... (check one with "x")

[ ] bug report
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57

Current behavior
I cannot add extra props for input components that uses a hidden input field (for accessible - "p-hidden-component").
This issue applies to all input components using hidden accessibility: dropdown, multiselect, checkbox, select etc.

Expected behavior
Possibility to add props to the "hidden accessible" input element.

Minimal reproduction of the problem with instructions
Why do I need this? I use @q42/floating-focus-a11y for better focusing focusable elements. When we focus on an element that uses "hidden accessibility", the hidden element will be highlighted.
before
In this case, the documentation suggests adding the attribute "focus-target" to the hidden element and indicating the identifier of the element that should be selected.

// primereact/components/dropdown/Dropdown.js, line 785
renderKeyboardHelper() {
	return (
		<div className="p-hidden-accessible">
			<input
				ref={el => (this.focusInput = el)}
				id={this.props.inputId}
				type="text"
				readOnly
				aria-haspopup="listbox"
				onFocus={this.onInputFocus}
				onBlur={this.onInputBlur}
				onKeyDown={this.onInputKeyDown}
				disabled={this.props.disabled}
				tabIndex={this.props.tabIndex}
				aria-label={this.props.ariaLabel}
				aria-labelledby={this.props.ariaLabelledBy}
				focus-target={this.id}
			/>
		</div>
	);
}

after
The feature can be solved by adding prop "keyboardHelperProps" for pass props or "renderKeyboardHelper".
Suggest:

renderKeyboardHelper() {
	let keyboardHelperProps = {
		ref: el => (this.focusInput = el),
		id: this.props.inputId,
		type: "text",
		readOnly: true,
		"aria-haspopup": "listbox",
		onFocus: this.onInputFocus,
		onBlur: this.onInputBlur,
		onKeyDown: this.onInputKeyDown,
		disabled: this.props.disabled,
		tabIndex: this.props.tabIndex,
		"aria-label": this.props.ariaLabel,
		"aria-labelledby": this.props.ariaLabelledBy
	};
	if (this.props.renderKeyboardHelper) {
		return this.props.renderKeyboardHelper(keyboardHelperProps);
	}
	return (
		<div className="p-hidden-accessible">
			<input
				{...keyboardHelperProps}
			/>
		</div>
	);
}
// or
renderKeyboardHelper() {
	return (
		<div className="p-hidden-accessible">
			<input
				...
				{...this.props.keyboardHelperProps}
			/>
		</div>
	);
}

Please tell us about your environment:
Windows, npm

  • React version:
    17

  • PrimeReact version:
    6.0.2

  • Browser:
    all

  • Language:
    all

@mcandu mcandu added the Type: New Feature Issue contains a new feature or new component request label Aug 19, 2021
@melloware melloware added the Component: Accessibility Issue or pull request is related to WCAG or ARIA label Apr 9, 2022
@melloware melloware self-assigned this Sep 14, 2022
@melloware melloware added this to the 8.6.0 milestone Sep 14, 2022
melloware added a commit to melloware/primereact that referenced this issue Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Accessibility Issue or pull request is related to WCAG or ARIA Type: New Feature Issue contains a new feature or new component request
Projects
None yet
3 participants