Skip to content

SearchBox role is hardcoded and can not be changed. #14914

@ilyatum

Description

@ilyatum

Environment Information

  • Package version(s): 7.128.1

Describe the issue:

In some cases search box is a part of a larger region with a role 'search'. In this case role of the wrapper for a SearchBox need to be change to 'presentation'. However, setting role attribute on a SearchBox control has no effect, it remains "search" for a wrapper and "searchbox" for input.

Reason is that these roles are hard coded and can not be changed. This is the code from SearchBox.base.tsx

  <div **role="search**" ref={this._rootElement} className={classNames.root} onFocusCapture={this._onFocusCapture}>
    <div className={classNames.iconContainer} onClick={this._onClickFocus} aria-hidden={true}>
      <Icon iconName="Search" {...iconProps} className={classNames.icon} />
    </div>
    <input
      {...nativeProps}
      id={id}
      className={classNames.field}
      placeholder={placeholderValue}
      onChange={this._onInputChange}
      onInput={this._onInputChange}
      onBlur={this._onBlur}
      onKeyDown={this._onKeyDown}
      value={value}
      disabled={disabled}
      **role="searchbox"**
      aria-label={ariaLabel}
      ref={this._inputElement}
    />

At least it should be possible to change the role of the outer element.

Actual behavior:

Generated HTML for a SearchBox wrapper has a hard coded role of 'searchbox'.

Expected behavior:

Generated HTML for a SearchBox wrapper has a role attribute set as specified, e.g. "presentation".

Priorities and help requested (not applicable if asking question):

Are you willing to submit a PR to fix? (Yes, No)

Yes.

Requested priority: (Blocking, High, Normal, Low)

Normal.

Products/sites affected: (if applicable)

Word WAC.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions